Java.lang Package Classes

Java Package - getImplementationVersion() Method



The java.lang.Package.getImplementationVersion() method returns the version number of the specification that this package implements. This version string must be a sequence of nonnegative decimal integers separated by "."'s and may have leading zeros. When version strings are compared the most significant numbers are compared.

Syntax

public String getSpecificationVersion()

Parameters

No parameter is required.

Return Value

Returns the specification version, null is returned if it is not known.

Exception

NA.

Example:

The example below shows how to use java.lang.Package.getImplementationVersion() method.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    //create a java util package object
    Package p = Package.getPackage("java.util");

    //print the version specification of this package
    System.out.println(p.getImplementationVersion());
  }
}

The possible output of the above code could be:

1.8.0_141

❮ Java.lang - Package