Javatpoint Logo
Javatpoint Logo

Java InetAddress equals() method

The 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

Overrides

equals() method in class Object

Returns

The equals() method returns Boolean vale true, if both the objects are the equivalent else it returns false.

Example 1

Test it Now

Output:

Host Name 1: www.javatpoint.com
Host Name 2: www.javatpoint.com
Both are equals

Example 2

Test it Now

Output:

Host Name 1: www.javatpoint.com
Host Name 2: www.google.com
Both the Inet Addresses are unequal

Next TopicInetAddress Class





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA