示例:
public class Main {
public static void main(String[] args) {
Integer obj1 = 100;
Integer[] obj2 = new Integer[]{100, 101};
System.out.println(obj1.getClass());
System.out.println(obj1.getClass().getCanonicalName());
System.out.println(obj1.getClass().isArray());
System.out.println();
System.out.println(obj2.getClass());
System.out.println(obj2.getClass().getCanonicalName());
System.out.println(obj2.getClass().isArray());
}
}
运行结果:
class java.lang.Integer
java.lang.Integer
false
class [Ljava.lang.Integer;
java.lang.Integer[]
true