+ 2
What is "enum" used for?
Java
2 Respuestas
+ 2
enums are used when a variable (especially a method parameter) can only take one out of a small set of possible values.
Enums improve both likelihood of correctness and readability without writing a lot of boilerplate.
If you use enums instead of integers or data-type, you increase compile-time checking and avoid errors from passing in invalid constants
0
readable, easy-to-remember markers for various status, e.g.
enum Suit {Heart, Diamond, Club, Spade};
is better than numeric codes. Suit.Diamond take less memory than "Diamond" String