Reputation:
What I mean is
interface A <T> {
}
class AImpl implements A < Integer > { // why not A< int >
}
I have read this article and googled it but still I have no idea why it is only for Object and not for primitive data types(int, void)?
Upvotes: 0
Views: 513
Reputation: 3300
Generics don't work for int, float, boolean, etc. because primitive types do not have all of the associated metadata and structures that Object based types have. In Java primitive types are just that, primitive. All of that associated metadata enables things like generics, reflection, subclassing, etc.
Upvotes: 1
Reputation: 1500165
It's not just wildcards - Java generics simply don't support primitive types as type arguments at all.
See the Java Generics FAQ for more information about Java Generics in general, and this question in particular.
Upvotes: 3