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