interface Shape {
void draw (Canvas c);
}
class Circle implements Shape { .. }
class Rectangle implements Shape { .. }
Das folgende
void drawAll (List<Shape> xs) {
for (Shape x : xs) { x.draw (this); }
}
ist nicht auf List<Circle> anwendbar!
Besser:
void drawAll (List<S extends Shape> xs) {
for (S x : xs) { x.draw (this); }
}