Package is collection of classes , interfaces and sub packages. Package must be a first statement of a class. To get package details getPackage() method is given in java.lang.Class . getPackage() method returns Package. Package is a class presented in java.lang package. See the below example for better understanding .


import java.lang.reflect.Method;

class Sample
    public static void main(String[] args) throws Exception
        Class c1=Class.forName("");
        Package p=c1.getPackage();


Output :