Java getSpecificationVendor() 方法



描述

Java Package getSpecificationVendor() 方法返回擁有和維護實現此包的類的規範的組織、供應商或公司的名稱。

宣告

以下是 java.lang.Package.getSpecificationVendor() 方法的宣告

public String getSpecificationVendor()

引數

返回值

此方法返回規範供應商,如果未知則返回 null。

異常

獲取 java.lang 包的規範供應商示例

以下示例演示了 java.lang.Package.getSpecificationVendor() 方法的使用。在此程式中,我們建立了一個 Package 變數併為其分配了 java.lang 包物件。然後使用 getSpecificationVendor() 方法列印包的規範供應商。

package com.tutorialspoint;

public class PackageDemo {

   public static void main(String[] args) {

      // get the java package
      Package pack = Package.getPackage("java.lang");

      // print the package specification vendor
      System.out.println(pack.getSpecificationVendor());
   }
}

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

null

獲取自定義包的規範供應商示例

以下示例演示了 java.lang.Package.getSpecificationVendor() 方法的使用。在此程式中,我們建立了一個 Package 變數併為其分配了 com.tutorialspoint 包物件。然後使用 getSpecificationVendor() 方法列印包的規範供應商。

package com.tutorialspoint;

public class PackageDemo {

   public static void main(String[] args) {

      // get the java package
      Package pack = Package.getPackage("com.tutorialspoint");

      // print the package specification vendor
      System.out.println(pack.getSpecificationVendor());
   }
}

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

null

獲取 java.util 包的規範供應商示例

以下示例演示了 java.lang.Package.getSpecificationVendor() 方法的使用。在此程式中,我們建立了一個 Package 變數併為其分配了 java.util 包物件。然後使用 getSpecificationVendor() 方法列印包的規範供應商。

package com.tutorialspoint;

public class PackageDemo {

   public static void main(String[] args) {

      // get the java package
      Package pack = Package.getPackage("java.util");

      // print the package specification vendor
      System.out.println(pack.getSpecificationVendor());
   }
}

輸出

讓我們編譯並執行上述程式,這將產生以下結果:

null
java_lang_package.htm
廣告

© . All rights reserved.