Java PropertyPermission hashCode() 方法



描述

java PropertyPermission hashCode() 方法返回此物件的雜湊碼值。雜湊碼由許可權名稱確定。

宣告

以下是 java.util.PropertyPermission.hashCode() 方法的宣告

public int hashCode()

引數

返回值

此方法返回此物件的雜湊碼的整數值。

異常

獲取具有讀寫許可權的 PropertyPermission 的雜湊碼示例

以下示例演示了 Java PropertyPermission hashCode() 方法的使用,以獲取許可權物件的雜湊碼。我們構建了 PropertyPermission 物件,然後使用 hashCode() 方法列印許可權物件的雜湊碼。

package com.tutorialspoint;

import java.util.PropertyPermission;

public class PropertyPermissionDemo {
   
   public static void main(String[] args) {

      // Build property permissions
      PropertyPermission permission = new PropertyPermission("java.home.*", "read,write");
      System.out.println(permission.hashCode());
   }
}

輸出

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

596176935

獲取具有讀取許可權的 PropertyPermission 的雜湊碼示例

以下示例演示了 Java PropertyPermission hashCode() 方法的使用,以獲取許可權物件的雜湊碼。我們構建了 PropertyPermission 物件,然後使用 hashCode() 方法列印許可權物件的雜湊碼。

package com.tutorialspoint;

import java.util.PropertyPermission;

public class PropertyPermissionDemo {
   
   public static void main(String[] args) {

      // Build property permissions
      PropertyPermission permission = new PropertyPermission("java.home.usr", "read");
      System.out.println(permission.hashCode());
   }
}

輸出

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

1695459921
java_util_propertypermission.htm
廣告

© . All rights reserved.