Java InetAddress equals() methodThe equals() method of Java InetAddress class compares this object against the specified object. It returns a boolean value 'true' if the argument is not null and it represents the exact IP address as this object. Syntax:Parameters:The parameter 'obj' represents the object to be compared with this object Overridesequals() method in class Object ReturnsThe equals() method returns Boolean vale true, if both the objects are the equivalent else it returns false. Example 1Test it NowOutput: Host Name 1: www.javatpoint.com Host Name 2: www.javatpoint.com Both are equals Example 2Test it NowOutput: Host Name 1: www.javatpoint.com Host Name 2: www.google.com Both the Inet Addresses are unequal
Next TopicInetAddress Class
|