Java我怎么知道一个类对象是一个接口还是一个类?
package org.nhooo.example.lang;
public class CheckForInterface {
public static void main(String[] args) {
//检查Cloneable是接口还是类
Class clazz = Cloneable.class;
boolean isInterface = clazz.isInterface();
System.out.println("Cloneable is an interface = " + isInterface);
//检查String是接口还是类
clazz = String.class;
isInterface = clazz.isInterface();
System.out.println("String is an interface = " + isInterface);
}
}Cloneable is an interface = true String is an interface = false
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短