Consider this example (typical in OOP books):
I have an Animal class, where each Animal can have many friends. And subclasses like
Animal
Additionally you can ask the method to return the value in a given type this way
T methodName(Class var);
More examples here at Oracle Java documentation