Can enum have int values?

Since Enums can be any integral type ( byte , int , short , etc.) , a more robust way to get the underlying integral value of the enum would be to make use of the GetTypeCode method in conjunction with the Convert class: enum Sides { Left, Right, Top, Bottom } Sides side = Sides.

Read more

Are Java enums ints?

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 more