public static void main(String[] args) {
C c = new C();
F f = new F();
System.out.println("c是否为C类型 "+(c instanceof C));
System.out.println("f是否为F类型 "+(f instanceof F));
System.out.println("array是否为int[] "+(array instanceof int[]));
}
static int[] array = {1,2,3,4,5,6,7,8,9};
static class C {
}
static class F{
}
java判断object的类型时使用instanceof
最新推荐文章于 2024-11-12 21:14:07 发布