Java Data Type Tutorial - Java Short.compare(short x, short y)








Syntax

Short.compare(short x, short y) has the following syntax.

public static int compare(short x,  short y)

Example

In the following code shows how to use Short.compare(short x, short y) method.


public class Main {
   public static void main(String[] args) {
     short s1 = 1;
     short s2 = 2;
     System.out.println( Short.compare(s1,s2));
   }
}

The code above generates the following result.