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.
14 lines
367 B
14 lines
367 B
public class Main {
|
|
public static void main(String[] args) {
|
|
Animal[] animals = new Animal[2];
|
|
animals[0] = new Dog();
|
|
animals[1] = new Cat();
|
|
|
|
for (Animal animal : animals) {
|
|
animal.makeSound();
|
|
if (animal instanceof Swimmable) {
|
|
((Swimmable) animal).swim();
|
|
}
|
|
}
|
|
}
|
|
}
|