The java.util.PropertyPermission.hashCode() method returns the hash code value for this object. The hash code is determined from the permissions name.
Following is the declaration for java.util.PropertyPermission.hashCode() method
public int hashCode()
NA
This method returns integer value for the hash code of this object.
NA
The following example shows the usage of java.util.PropertyPermission.hashCode() method.
package com.tutorialspoint; import java.util.Date; import java.util.Hashtable; import java.util.PropertyPermission; public class PropertyPermissionDemo { private static Hashtable<PropertyPermission, Date> validity; public static void main(String[] args) { // Build property permissions validity collection validity = new Hashtable<PropertyPermission, Date>(); validity.put(new PropertyPermission("java.home.usr", "read"), new Date(2012, 12, 31)); // Get permissions and validity checkFilePermissions("java.home.usr"); } private static void checkFilePermissions(String path) { // Hashcode is calculated by name PropertyPermission permission = new PropertyPermission(path, "read"); System.out.println("Has permissions on "+path+ " for read, Till: "+validity.get(permission)); } }
Let us compile and run the above program, this will produce the following result −
Has permissions on java.home.usr for read, Till: Fri Jan 31 00:00:00 IST 3913