Is there a way in Java to declare an enumeration whose values can be used together? For example:
enum FileAccess { Read, Write, ReadWrite }
Is it possible to define ReadWrite as Read | Write (or anything that would yield the same result)?
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.
You use EnumSet:
This is actually somewhat more elegant than the C#/.NET way, IMO – aside from anything else, you can easily distinguish between a set and a single value.