Tuesday, 13 October 2015

Package Information

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 void main(String[] args) {
           Class myObjectClass = MyObject.class;
           Package packageInfo = myObjectClass.getPackage();
           String packName = packageInfo.getName();
Output: reflect

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...