Pages

Java Package class

public class Package (java.lang)

Package objects contain version information about the implementation and specification of a Java package. The version information is retrieved and made available by the ClassLoader instance that loaded the class(es).

Typically, it is stored in the manifest that is distributed with the classes.

Example of Package Class

package com.self.practise;

public class PackageClass {

 public static void main(String[] args) {
  
  
  Package pac = Package.getPackage("java.lang");
 
                System.out.println(pac.getImplementationVersion());
  System.out.println(pac.getSpecificationVendor());
  System.out.println(pac.getImplementationTitle());
  System.out.println(pac.isSealed());
  System.out.println(pac.getSpecificationTitle());
  

 }

}

Output of the program
1.7.0_75
Oracle Corporation
Java Runtime Environment
false
Java Platform API Specification

How to write an immutable Class in Java

No comments:

Post a Comment