public class GetClassInfo {
public static void main(String[] args){
Class clazz = Users.class;
//获取类名
String className = clazz.getName();
System.out.println(className);
//获取包名
Package p = clazz.getPackage();
System.out.println(p.getName());
//获取超类
Class superClass = clazz.getSuperClass();
System.out.println(superClass.getName());
//获取该类实现的所有接口
Class[] interfaces = clazz.getInterFaces();
for(Class inter : interfaces){
System.out.println(inter.getName());
}
}
}
08-06
2932
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-30
3732
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-09