NetworkInterface equals Example

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


NetworkInterface class equals example. public 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 NetworkInterface as this object.

Here is the code
/*
 * @ # Equals.java
 * A class repersenting use to Equals method 
 * of URL 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 {

        byte b[] {127001};
        InetAddress inetAddress = InetAddress.getByAddress(b);

        NetworkInterface networkInterface, networkInterface1;

        networkInterface = NetworkInterface.getByInetAddress(inetAddress);
        networkInterface1 = NetworkInterface.getByName("lo");

        System.out.println("networkInterface and networkInterface1 is equals " + networkInterface.equals(networkInterface1));
    }
}

Output
networkInterface and networkInterface1 is equals true

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

HOME | COPYRIGHT | CONTACT US