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 M退休祝福语结婚简短
12 虎年文案简短祝福语长辈
13 朋友之间互勉祝福语简短
14 信件告别祝福语大全简短
15 最美母女祝福语简短英文
16 男友人新婚祝福语简短
17 护士辞职送行祝福语简短
18 安徽旅行祝福语大全简短