Java - What is the output: enum value compare

Question

What is the output from the following code

enum Level {
  LOW, MEDIUM, HIGH, URGENT;
}
enum Color {
  RED, GREEN, BLUE;
}

public class Main {
  public static void main(String[] args) {
    int diff = Color.RED.compareTo(Level.LOW); // A compile-time error
    System.out.println(diff);
  }
}


Click to view the answer

The method compareTo(Color) in the type Enum is not applicable for the arguments (Level)

Note

The code will not compile because it tries to compare the two enum constants, belonging to different enum types: