Reputation: 3004
Today I was looking at the following piece of Android source code:
The type is declared as:
public class IntArrayEvaluator implements TypeEvaluator<int[]>
My understanding of Java generics is that primitive types and arrays are not supported.
Am I correct in that understanding?
If I am correct is this something unique to Android's implementation of Java?
Upvotes: 1
Views: 199
Reputation: 140319
int[]
is a reference type, and so can be used as a generic type parameter; this is not the same thing as the primitive int
type. There is nothing peculiar to Android about this.
Upvotes: 1
Reputation: 37645
No, you are not correct. int[]
is allowed as a type parameter in both Android and standard Java. This is because int[]
is a reference type. int
, on the other hand, is a primitive type and is not allowed as a type parameter in either.
Upvotes: 1
Reputation: 2614
Arrays are supported because internally one object will be created in Heap for all Primitive array as wrapper type.
but primitive types are not applicable.
Upvotes: 1