- 1
How to check if a type is a primtive array in Java?
2 Respostas
+ 2
An array itself is always an object, only the elements inside it can be primitive. It also can store objects.
Eg - int[] arr = new int[5];
Here arr is an object and it can store 5 integer type elements.
+ 2
As Avinesh mentioned arrays are objects.
So you can use getClass().getSimpleName() to check if the array contains primitves.
This method returns a String:
int[] arr -> arr.getClass().getSimpleName() returns "int[]"
https://code.sololearn.com/calrsLqa05b6/?ref=app