What are the uses of the java’s int Enum pattern? can anyone help me to know more about the int enum pattern?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The int enum pattern (the use of
static final int CONSTANT_NAMEinstead of usingenums) is a historical artifact.Originally, Java did not support enums, so in order to provide flags to methods and the likes, this was the only approach.
It provides some of the benefits of the modern enum approach:
switchstatementsbut they also lack a few important features
To conclude: if you are working on a Java 1.5+ project, always use then modern
enumpattern instead of the classical int Enum pattern.