package com.shrimpking.t6;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/12 17:39
*/
interface A {}
class X {
class B {}
public static A getA(){
class C implements A{}
return new C();
}
}
enum D {}
public class DetecType
{
public static void main(String[] args)
{
Integer in = 2;
Class c1 = int.class;
System.out.printf("c1是不是基本数据类型:%b%n",c1.isPrimitive());
Class c2 = in.getClass();
System.out.printf("c2是不是基本数据类型:%b%n",c2.isPrimitive());
int[] arr = new int[3];
Class c3 = arr.getClass();
System.out.printf("c3是不是数组类型:%b%n",c3.isArray());
Class c4 = D.class;
System.out.printf("c4是不是枚举类型:%b%n",c4.isEnum());
Class c5 = A.class;
System.out.printf("c5是不是接口类型:%b%n",c5.isInterface());
Class c6 = X.B.class;
System.out.printf("c6是不是内部类:%b%n",c6.isMemberClass());
Class c7 = X.getA().getClass();
System.out.printf("c7是不是局部内部类:%b%n",c7.isLocalClass());
A a = new A(){};
Class c8 = a.getClass();
System.out.printf("c8是不是匿名类:%b%n",c8.isAnonymousClass());
System.out.printf("c8是不是接口:%b%n",c8.isInterface());
}
}
09-09
661
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
09-06
289
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)