所有类型的Class
/*
* 所有类型的Class
* */
import java.lang.annotation.ElementType;
public class ClassDemo {
public static void main(String[] args) {
// 类的Class
Class c1 = Object.class;
// 接口的Class
Class c2 = Comparable.class;
// 一维数组的Class
Class c3 = int[].class;
// 二维数组的Class
Class c4 = int[][].class;
// 注解的Class
Class c5 = Override.class;
// 枚举的Class
Class c6 = ElementType.class;
// 基本数据类型的Class
Class c7 = int.class;
// 包装类的Class
Class c8 = Integer.class;
// void的Class
Class c9 = void.class;
// Class的Class
Class c10 = 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);
System.out.println(c9);
System.out.println(c10);
// 两个不一样的相同类型的数组Class相同
int[] a = new int[10];
int[] b = new int[1024];
// 不同
System.out.println(a.hashCode());
System.out.println(b.hashCode());
// 相同
System.out.println(a.getClass().hashCode());
System.out.println(b.getClass().hashCode());
}
}