I have a enum for various operations, I want to iterate through the enum Operations
public enum Operations { create,update,delete,view,compare,login }
How can i achieve this?
Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc. You can iterate the contents of an enumeration using for loop, using forEach loop and, using java.
Duplicates in enum type can be done in 2 ways : Duplicate enum members (2 or more members with same name) 2 or more members with same value.
An EnumSet is a specialized Set collection to work with enum classes. It implements the Set interface and extends from AbstractSet: Even though AbstractSet and AbstractCollection provide implementations for almost all the methods of the Set and Collection interfaces, EnumSet overrides most of them.
for (Operations op : Operations.values()) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With