After doing some research, I see since java 1.5 it is preferable to manage constants (or key properties) in enum which are declared in a “constant” class.
I’d like to know what is the proper way to implement these enum to get as simple as possible the value of an element of an enum whatever its type.
Example : is it possible to have the value of “Constant.Messages.WARNING” where Messages is :
public enum Messages {
WARNING("main.message.warning")
}
Thank you.
You can customize enums as other classes in Java with few exceptions.
I’ll use the same example, but it uses
toStringwithoutgetMessage, so you can use enums in those places wheretoStringis called (for example, inSystem.out.printlnor any logging methods).