You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
538 B

public class Main {
public void main(){
Animal cat = new Cat();
Animal dago = new Dog();
cat.makeVoice();
dago.makeVoice();
if(cat instanceof Swimmable){
System.out.println("猫会游泳");
}
else{
System.out.println("猫不会游泳");
if (dago instanceof Swimmable){
System.out.println("大狗会游泳");
}
else{
System.out.println("大狗不会游泳");
}
}
}
}