Copyright © tutorialspoint.com

Java - equals() Method

previous next


Description:

The method determines whether the Number Object that invokes the method is equal to the argument.

Syntax:

public boolean equals(Object o)

Parameters:

Here is the detail of parameters:

Return Value :

Example:

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

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

This produces following result:

false
true
false

previous next

Copyright © tutorialspoint.com