Java API Tutorial - Java InetAddress.hashCode()








Syntax

InetAddress.hashCode() has the following syntax.

public int hashCode()

Example

In the following code shows how to use InetAddress.hashCode() method.

/*from   w w w  .j  a  va2s .c  o  m*/
import java.net.InetAddress;

public class Main {
  public static void main(String[] argv) throws Exception {
    byte[] ipAddr = new byte[] { 127, 0, 0, 1 };
    InetAddress addr = InetAddress.getByAddress(ipAddr);
    System.out.println(addr.hashCode());
  }
}

The code above generates the following result.