Java Enum - what are the benefits?

Question | Aug 11, 2016 | mnagu 

In java, enum types are introduced to replace enumerated set of int constants and enumerated set of String constants, say, set of colors in a palette, set of planets in the solar system etc., Unlike enums in other languages, Java enum types can be as simple as a simple constant name to as complex as a full-fledged class with attributes and methods.

Here is an example:

 enum SodaSize{
     SMALL(16), MEDIUM(21), LARGE(30);
     SodaSize(int size){
         this.size = size;
     }
     private int size;
     public String getSize(){
         return this.size + " ounces.";
     }
 }

What are the benefits of enum type over the enumerated int or string constants?

2015 nextptr