You shouldn’t depend on the int value of an enum , only on its actual value. Enums in Java are a different kind of monster and are not like enums in C, where you depend on their integer code. Regarding the example you provided in the question, Font. PLAIN works because that’s just an integer constant of the Font class.
Read moreCan Java enum have multiple values?
The Enum constructor can accept multiple values .2 Eyl 2021
Read moreCan enum have multiple constructor Java?
Yes, they can have more than one constructor .
Read moreCan we define multiple enum inside a class?
java file may have only one public class. You can therefore declare only one public enum in a . java file . You may declare any number of package-private enums.
Read moreCan we assign value to enum?
You can assign different values to enum member . A change in the default value of an enum member will automatically assign incremental values to the other members sequentially.
Read moreHow do I display the value of an enum?
An enumeration is a great way to define a set of constant values in a single data type. If you want to display an enum’s element name on your UI directly by calling its ToString() method , it will be displayed as it has been defined.
Read more