Because that unbound generic type erases to Object
, it'd be the same as passing Object
in your constructor:
public class Foo {
Object o;
public Foo(Object o) {
this.o = o;
}
}
...but like passing a blank Object
, unless you're doing something clever, this has little practical value.
You see benefits and wins if you pass in bound generics instead, meaning that you can actually have guarantees around the type that you care about.
public class Foo<T extends Collection<?>> {
T collection;
public Foo(T collection) {
this.collection = collection;
}
}
Effectively, this is more about flexibility than it being something revolutionary. If you want the flexibility to pass in a specific category of types, then you have the power to do so here. If you don't, then there's nothing wrong with standard classes. It's merely here for your convenience, and since type erasure is still a thing, an unbound generic is the same (and has the same utility) as passing Object
.
<U> Bar(U a, U b)
?