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








Syntax

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

public boolean equals(Object obj)

Example

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

If you just want to check the equality for two short values, equals method from Short class is the way to go.

public class Main {
  public static void main(String[] args) {
    Short shortValue1 = new Short("10");
    Short shortValue2 = new Short("11");
    
    System.out.println(shortValue1.equals(shortValue2));
  }
}

The output: