I'm learning Java from the Oracle tutorials, and I've just reached Generics.
So we can use a bounded type parameter to restrict the types that can be used as type arguments. The tutorial brings the following method as an example:
class Box<T> {
...
public <U extends Number> void inspect(U u){
System.out.println("T: " + t.getClass().getName());
System.out.println("U: " + u.getClass().getName());
}
}
And I wonder - what is the benefit of using a bounded type parameter in a method? To be more precise, what is the benefit of the method above rather than:
public void inspect(Number u)
?