Java String equals() method

equals() method compares two string based on the their content.

Syntax

parameter

anObject: Object to be compared with the current String.

Returns

It returns true when the current String is equivalent to the given String Otherwise, it returns false.

Java String equals() method Example1:

Output:

Java String equals() method Example 2:

Output:

Java String equals() method Example 3:

Output:

Leave a Comment