Java how to access inner enum class

后端 未结 3 1160
攒了一身酷
攒了一身酷 2021-02-06 23:24
public class Constant {

  ......

  public enum Status {
    ERROR,
    WARNING,
    NORMAL
  }

  ......

}

After compiling I got a class file named

3条回答
  •  长发绾君心
    2021-02-06 23:45

    Since this was not mentioned before, in the original question the enum has the public access modifier which means we should be able to do Constant.Status.ERROR.toString() from anywhere. If it was set to private it would have been available only to the class: Constant. Similarly it is accessible within the same package in case of no modifier (default).

提交回复
热议问题