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.