如何在java中迭代枚举

时间:2011-05-30 09:46:18

标签: java enums

我有各种操作的枚举,我想遍历枚举Operations

public enum Operations 
{
create,update,delete,view,compare,login
}

我怎样才能实现这个目标?

1 个答案:

答案 0 :(得分:49)

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