Java Data Type Tutorial - Java Integer.compare(int x, int y)








Syntax

Integer.compare(int x, int y) has the following syntax.

public static int compare(int x,  int y)

Example

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

public class Main {
  public static void main(String[] args) {
    if(Integer.compare(1,  1)== 0){
       System.out.println("Equals");
    }
    
  }
}

The code above generates the following result.