开发者

How to iterate through enum in java [duplicate]

开发者 https://www.devze.com 2023-03-09 00:13 出处:网络
This question already has answers here: A for-loop to iterate over an enum in Java (9 answers) 开发者_开发技巧
This question already has answers here: A for-loop to iterate over an enum in Java (9 answers) 开发者_开发技巧 Closed 6 years ago.

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?


for (Operations op : Operations.values()) {
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消