rendered paste body class Ape {
}
class Gorilla extends Ape {
}
class Schimpanzee extends Ape {
}
void doIt(Ape ape) {
System.err.println("Basklass");
}
void doIt(Schimpanzee schimpanzee) {
System.err.println("Apa 1: " + schimpanzee.getClass().getName());
}
void doIt(Gorilla gorilla) {
System.err.println("Apa 2: " + gorilla.getClass().getName());
}
public void testApa() {
List<Ape> apa = new LinkedList<Ape>();
doIt(new Ape());
doIt(new Schimpanzee());
doIt(new Gorilla());
apa.add(new Ape());
apa.add(new Schimpanzee());
apa.add(new Gorilla());
for(Ape a : apa) {
doIt(a);
}
}