testObj() , Java Integer[]. main() String, Array Integer, .
If you were to change the second test from Arrayto Integer[], it would work as you expected:
else if (obj.testObj() instanceof Integer[])
System.out.println("Integer Array");
Reason for use obj.testObj() instanceof Arraydoes not work, because the class java.lang.reflect.Arrayis not really a superclass of Java arrays. According to the JavaDoc page, the class "provides static methods for dynamically creating and accessing Java arrays" - this is not the array itself, it is just a utility for creating and accessing arrays.
source
share