Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

They are equal.

Example 2

Test it Now

Output:

They are not equal.

Example 3

Test it Now

Output:

The numbers are equal.

Example 4

Test it Now

Output:

The numbers are not equal.
Next TopicJava Character



Help Others, Please Share

facebook twitter pinterest