java 枚举嵌套枚举_Java中的嵌套枚举?

在OP的一些评论之后,我更新了我的代码.使用语法变得丑陋,在切换块中可能无法正常工作,但我相信这可以实现OP的目标:

import java.util.*;

public class HelloWorld

{

public static void main(String []args)

{

// Different services are not equal

System.out.println(Service.REGISTER + "==" + Service.LOGIN + " :: " + Service.REGISTER.equals(Service.LOGIN));

// Same service is equal

System.out.println(Service.REGISTER + "==" + Service.REGISTER + " :: " + Service.REGISTER.equals(Service.REGISTER));

// Even after changing the state

Service tmp = Service.REGISTER;

Service.REGISTER.setState(Service.ServiceState.State.Failed);

System.out.println(Service.REGISTER + "==" + tmp + " :: " + Service.REGISTER.equals(tmp));

Service.REGISTER.setState(Service.Servi

你可能感兴趣的:(java,枚举嵌套枚举)