Java Character equals() Method

The equals(Object obj) method of character class compares the object with the specified object. The result is true if and only if the argument is not null and the Character object has the same char value as represented by the object.

Syntax

Parameter

The above method requires only one parameter:

The object that needs to be compared.

Return Value

The equals(Object obj) method returns true if the objects are same. Otherwise, the method returns false.

Example 1

Output:

They are equal.

Example 2

Output:

They are not equal.

Example 3

Output:

The numbers are equal.

Example 4

Output:

The numbers are not equal.