hashCode(): This method is available in the java.net.SocketPermission class of Java.
Syntax:
int java.net.SocketPermission.hashCode()
This method returns the hash code value for this object.
Parameters: NA
Returns: a hash code value for this object.
Exceptions: NA
Approach
Java
package com.SocketPermission;import java.net.SocketPermission;public class SocketPermissionhashCode {public static void main(String[] args) {String host = "google.com";String action = "connect";SocketPermission socketPermission = new SocketPermission(host, action);System.out.println(socketPermission.hashCode());}}
Output:
-1871726861
Some other methods of SocketPermission
SocketPermission(String, String): This method creates a new SocketPermission object with the specified actions. The host is expressed as a DNS name, or as a numerical IP address.
equals(Object): This method checks two SocketPermission objects for equality.
getActions(): This method returns the canonical string representation of the actions. Always returns present actions in the following order: connect, listen, accept, resolve.
hashCode(): This method returns the hash code value for this object.
implies(Permission): This method checks if this socket permission object "implies" the specified permission.
newPermissionCollection(): This method returns a new PermissionCollection object for storing SocketPermission objects.
No comments:
Post a Comment