Java equals () method
equals () method is used to determine the parameters and methods of the Number object into equality.
grammar
public boolean equals(Object o)
parameter
o - any object.
return value
As Number object is not Null, and parameter types and numerical methods are equal and returns True, otherwise False.
Examples
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)); } }
Compile the above program, the output is:
false true false