所有类型的Class
1.6、所有类型的Class
public class Test04 {
public static void main(String[] args) {
Class c1 = Object.class; //类
Class c2 = Comparable.class; //接口
Class c3 = String[].class; //一维数组
Class c4 = int[][].class; //二维数组
Class c5 = Override.class; //注解
Class c6 = ElementType.class; //枚举
Class c7 = void.class; //void
Class c8 = Class.class; //Class
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
System.out.println(c4);
System.out.println(c5);
System.out.println(c6);
System.out.println(c7);
System.out.println(c8);
//只要元素和维度一样,就是同一个Class
int[] a1 = new int[10];
int[] a2 = new int[100];
System.out.println(a1.getClass().hashCode());
System.out.println(a2.getClass().hashCode());
}
}
注意:只要元素和维度一样,就是同一个Class
本文来自博客园,作者:小徐学狂,转载请注明原文链接:https://www.cnblogs.com/xd-study/p/13199839.html