WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Java - equals() Method Method


The method determines whether the Number object that invokes the method is equal to the object that is passed as an argument.


Syntex

public boolean equals(Object o)

Parameters

Any object.

Example

public class Test { 

   public static void main(String args[]) {
      Integer x = 2;
      Integer y = 5;
      Integer z =2;
      Short a = 1;

      System.out.println(x.equals(y));  
      System.out.println(x.equals(z)); 
      System.out.println(x.equals(a));
   }
}

Output
false
true
false

Run example »