First page Back Continue Last page Overview Graphics
Generics – wildcards
<? extends T> – a family of Type subtypes
<? super T> – a family of Type supertypes
<?> - the set of all Types, or any
public class NumberBox<N extends Number> extends Box<N> {
public NumberBox() {
super();
}
// sum everything in the box
public double sum() {
double total = 0;
for(Number n : this.contents){
total += n.doubleValue();
}
}