InetSocketAddress hashCode Example

Started by VelMurugan, Dec 30, 2008, 11:42 PM

Previous topic - Next topic

VelMurugan

InetSocketAddress hashCode Example

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

InetSocketAddress class hashCode example. public final int hashCode() Returns a hashcode for this socket address.

Here is the code


/*
* @ # GetAddress.java
* A class repersenting use to GetAddress method
* of InetSocketAddress class in java.net package
* version 23 June 2008
* author Rose India
*/

import java.net.*;

public class HashCode {

    public static void main(String[] args) throws Exception {
        //Get local host.
        InetAddress inetAddress = InetAddress.getLocalHost();

        InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 1313);

        //Gets InetAddress.
        System.out.println("HashCode " + inetSocketAddress.hashCode());
    }
}


Output
HashCode 2130708002

Source : codingdiary