如何在java中迭代枚举

2022-09-01 17:03:04

我有一个用于各种操作的枚举,我想遍历枚举Operations

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

我怎样才能做到这一点?


答案 1
for (Operations op : Operations.values()) {
    ...
}

答案 2