Package Information
From the Package object we can access to information about the package like its name, version, annotation etc.
package reflect;
class MyObject {
private Integer num;
}
public class ClassObject {
public static voidmain(String[] args) {
Class myObjectClass = MyObject.class;
Package packageInfo = myObjectClass.getPackage();
String packName = packageInfo.getName();
System.out.println(packName);
}
}
Output: reflect
No comments:
Post a Comment