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");
    /*  ww  w.  j a v a 2s.  c  o m*/
    System.out.println(shortValue1.equals(shortValue2));
  }
}

The output:





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable