Java Data Type Tutorial - Java Object.equals(Object obj)








Syntax

Object.equals(Object obj) has the following syntax.

public boolean equals(Object obj)

Example

In the following code shows how to use Object.equals(Object obj) method.

/* w  w w .  j a v  a2 s. c o  m*/
public class Main {

   public static void main(String[] args) {
      Integer x = new Integer(50);
      Float y = new Float(50f);

      System.out.println(x.equals(y));
      System.out.println(x.equals(50));

   }
}

The code above generates the following result.