I am currently working on a grails project. I’ve created an enum located on a certain project folder, and wanted to access it from a class located on another project folder.
My enum looks something like this:
public enum Options {
OPTION_1("Option_1"),
OPTION_2("Option_2"),
OPTION_3("Option_3");
final String option;
Options(String option) {
this.option = option;
}
}
Now, I am having a problem in calling that enum from a certain class in my application. For example:
Response{
option = new Option.OPTION_1("Option_1") //not sure on how to call an enum
}
But what I wanted to do here is to assign the enum to the property option in the Response {} section..
How will I properly do that?
Help please?
Thanks.
Enums are predefined objects, it will have a private constructor, You can not create a new instance with new. You just need to call Option.OPTION_1;