The package class provides methods to get information about the specification and implementation of a package. It provides methods such as getName(), getImplementationTitle(), getImplementationVendor(), getImplementationVersion() etc.
In this example, we are printing the details of java.lang package by invoking the methods of package class.
class PackageInfo{
public static void main(String args[]){
Package p=Package.getPackage("java.lang");
System.out.println("package name: "+p.getName());
System.out.println("Specification Title: "+p.getSpecificationTitle());
System.out.println("Specification Vendor: "+p.getSpecificationVendor());
System.out.println("Specification Version: "+p.getSpecificationVersion());
System.out.println("Implementaion Title: "+p.getImplementationTitle());
System.out.println("Implementation Vendor: "+p.getImplementationVendor());
System.out.println("Implementation Version: "+p.getImplementationVersion());
System.out.println("Is sealed: "+p.isSealed());
}
}
Output:package name: java.lang
Specification Title: Java Plateform API Specification
Specification Vendor: Sun Microsystems, Inc.
Specification Version: 1.6
Implemenation Title: Java Runtime Environment
Implemenation Vendor: Sun Microsystems, Inc.
Implemenation Version: 1.6.0_30
IS sealed: false
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India