How to create enum with numbers? And how to compare them with each other?

PS I had a "rating" system, which was in numbers 1, 3, 9 . More precisely, there was an ArrayList with class objects, in this class there was a field with a rating.

At the end, the rating of different objects was compared and selected with the highest rating.

I was advised to "hold" the rating using enum . But something to create enum with numbers does not work, as in this example, too.

How can I do that?

    1 answer 1

     public class EnumInt { enum Rating { ONE(1), THREE(3), NINE(9); private final int value; Rating(int value) { this.value = value; } public int getValue() { return value; } } public static void main(String[] args) { System.out.println(Rating.THREE.getValue() < Rating.NINE.getValue()); // true } }