How to compare two ints in java?

Question:
The user is asked to enter two positive integers. The program prints them in ascending order or states that they are equal.

Code:
import java.util.Scanner;
 
public class CompareInts {
  public static void main(String[] args) {
 
    Scanner sc = new Scanner(System.in);
 
    System.out.print("Enter 1st number: ");
    int i1 = sc.nextInt();
 
    System.out.print("Enter 2nd number: ");
    int i2 = sc.nextInt();
 
    if (i1 == i2) {
      System.out.println("Equal");
    } else if (i1 < i2) {
      System.out.println(i1 + " " + i2);
    } else {
      System.out.println(i2 + " " + i1);
    }
 
  }
} 
 

Output:
$ java CompareInts
Enter 1st number: 3
Enter 2nd number: 1
1 3