school/java/week10/Main.java

31 lines
547 B
Java
Raw Normal View History

2021-03-27 15:33:25 -04:00
interface Animal{
public void speak();
}
class Cat implements Animal{
@Override
public void speak(){
System.out.println("Meow Meow");
}
}
class Dog implements Animal{
@Override
public void speak(){
System.out.println("Woof Woof");
}
}
public class Main{
public static void main(String [] args){
Animal [] animals = {
new Dog(),
new Cat()
};
for(Animal animal : animals){
animal.speak();
}
}
}