InterfaceAddress hashCode Example

InterfaceAddress class hashCode example. This example shows you how to use hashCode method.


InterfaceAddress class hashCode example. public int hashCode() Returns a hashcode for this Interface address.

Here is the code
/*
 * @ # HashCode.java
 * A class repersenting use to HashCode method 
 * of InterfaceAddress class in java.net package
 * version 23 June 2008
 * author Rose India 
 */

import java.net.*;
import java.util.*;

public class HashCode {

    public static void main(String args[]) throws Exception {
        NetworkInterface networkInterface =
                NetworkInterface.getByName("eth0");

        List<InterfaceAddress> address =
                networkInterface.getInterfaceAddresses();

        for (InterfaceAddress interfaceAddress : address) {
            System.out.println("\nAddress " + interfaceAddress.getAddress());

            System.out.println("Hashcode " + interfaceAddress.hashCode());
        }
    }
}

Output
Address /fe80:0:0:0:219:d1ff:fe61:be38%2
Hashcode -33976457

Address /192.168.10.222
Hashcode -2125457931

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US