Java Integer equals() method

tutorial and example
tutorial and example

The equals()  method of Integer class compares the given object to the specified object.

 Syntax`

public boolean equals(Object obj)

 Parameters

The parameter ‘obj’ represents the object to be compared with.

 Overrides

The equals() method overrides equals in class Object

 Return Value

This method returns:

  • Boolean value true, if both the objects are identical
  • Else it returns false.

Example 1

Output

Example 2

Output