1

Today I was looking at the following piece of Android source code:

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/animation/IntArrayEvaluator.java

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?

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.