Saturday 16 August 2014

getPackage() : Find the Package details

You can get the package details by using the 'getPackage' method of the class java.lang.Class.

import java.util.*;

public class GetPackage {
    public static void main(String args[]){
        Set<Integer> mySet = new HashSet<> ();
        
        Package pack = mySet.getClass().getPackage();
        
        System.out.println("Information about the package");
        System.out.println("-------------------------------------------");
        System.out.println("Package Name : " + pack.getName());
        System.out.println("Vendor implemented : " + pack.getImplementationVendor());
        System.out.println("Implemented Version : " +pack.getImplementationVersion());
        System.out.println("TitleOf the package : " + pack.getImplementationTitle());
        System.out.println("-------------------------------------------");
    }
}

Output
Information about the package
-------------------------------------------
Package Name : java.util
Vendor implemented : Oracle Corporation
Implemented Version : 1.8.0_05
TitleOf the package : Java Runtime Environment
-------------------------------------------




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment