Dalszą część pozostawiam bez komentarza :)
interface Quacks {
void quack();
}
interface Walks {
void walk();
}
class Duck implements Quacks, Walks {
public void quack() {
System.out.println("Quack!");
}
public void walk() {
System.out.println("[a sound of a duck walking :P]");
}
}
public class Hunter {
<T extends Quacks & Walks> void shoot(T animal) {
animal.walk();
System.out.println("[a sound of a gunshot]");
animal.quack();
System.out.println("[a sound of a quacking, walking animal dying]");
}
public static void main(String[] args) {
new Hunter().shoot(new Duck());
}
}
Amazing ain't it ?
No comments:
Post a Comment