News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

InetSocketAddress equals Example

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

Previous topic - Next topic

VelMurugan

InetSocketAddress equals Example

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

InetSocketAddress class equals example. public final boolean equals(Object obj) Compares this object against the specified object. The result is true if and only if the argument is not null and it represents the same address as this object.

Here is the code


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

import java.net.*;

public class Equals {

    public static void main(String args[]) throws Exception {

        InetSocketAddress inetSocketAddress, inetSocketAddress1;

        inetSocketAddress = new InetSocketAddress("192.168.10.222", 1313);
        inetSocketAddress1 = new InetSocketAddress("192.168.10.222", 1313);
        System.out.println("inetSocketAddress and inetSocketAddress1 " +
                "is equals " + inetSocketAddress.equals(inetSocketAddress1));
    }
}


Output

inetSocketAddress and inetSocketAddress1 is equals true


Source : codingdiary