Java how to access inner enum class

You’ll be able to access it elsewhere like

import package.name.Constant;
//...
Constant.Status foo = Constant.Status.ERROR;

or,

import package.name.Constant;
import package.name.Constant.Status;
//...
Status foo = Status.ERROR;

To get the declared name of any enum element, use Enum#name():

Status foo = ...;
String fooName = foo.name();

Leave a Comment

tech