Home » Java programming language

Java Package getSpecificationVendor() method with example

Package Class getSpecificationVendor() method: Here, we are going to learn about the getSpecificationVendor() method of Package Class with its syntax and example.
Submitted by Preeti Jain, on December 05, 2019

Package Class getSpecificationVendor() method

  • getSpecificationVendor() method is available in java.lang package.
  • getSpecificationVendor() method is used to retrieve the name of the vendor that manages the specification of the classes or interface that is implemented by this package.
  • getSpecificationVendor() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • getSpecificationVendor() method does not throw an exception at the time of returning specification vendor of the package.

Syntax:

    public String getSpecificationVendor();

Parameter(s):

  • It does not accept any parameter.

Return value:

The return type of this method is String, it returns the name of the company who specializes in this package otherwise it returns null when specification vendor of the package is not known.

Example:

// Java program to demonstrate the example 
// of String getSpecificationVendor() of Package method

public class GetSpecificationVendor {
    public static void main(String[] args) {
        // Get Package by using getPackage() method
        Package pkg = Package.getPackage("java.util");

        // Get specification vendor of the package by using 
        // getSpecificationVendor() and stored in a variable
        // called svendor
        String svendor = pkg.getSpecificationVendor();

        // Display vendor of the package
        System.out.print("Package Vendor: ");
        System.out.print(svendor);
    }
}

Output

Package Vendor: Sun Microsystems, Inc.



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.