package com.liu.test03;
import java.lang.annotation.Annotation;
/**
* @author : liu
* 日期:17:03:17
* 描述:IntelliJ IDEA
* 版本:1.0
*/
public class Test04 {
//这是一个main方法:是程序的入口
public static void main(String[] args) {
Class cls = Student.class;
//获取运行时类的接口
Class[] interfaces = cls.getInterfaces();
for (Class s:interfaces
) {
System.out.println(s);
}
//得到父类的接口
//先得到父类的字节码信息
Class superclass = cls.getSuperclass();
//
//得到父类的接口
Class[] interfaces1 = superclass.getInterfaces();
for (Class c: interfaces1
) {
System.out.println(c);
}
//获取运行时类所在的包
Package aPackage = cls.getPackage();
System.out.println(aPackage);
String name = aPackage.getName();
System.out.println(name);
//获取运行时类的注解:
Annotation[] annotations = cls.getAnnotations();
for (Annotation a:annotations
) {
System.out.println(a);
}
}
}