Inet4Address Equals() Example

Returns true if this object is the same as the obj argument


Inet4Addressclass Equals() method example. This example shows you how to use Equals() method.This method Returns true if object is the same

Here is the code:-
/* 
 * @Program that returns true if the objects are the same.
 * Equals.java 
 * Author:-RoseIndia Team
 * Date:-28-Jun-2008
 */

import java.net.*;

public class Equals {

    public static void main(String[] argsthrows Exception {
        InetAddress i = Inet4Address.getByName("localhost");
        InetAddress ia = Inet4Address.getByName("192.168.10.222");
        //returns true if the objects are the same.
        System.out.println("Objects are same: " + i.equals(ia));
    }
}

Output of the program:-
 Objects are same: false

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

HOME | COPYRIGHT | CONTACT US