I have 3 String arrays with constants. eg:
String[] digit = {"one", "two", "three"};
String[] teen= {"ten", "twenty", "thirty"};
String[] anchors = {"hundred", "thousand", "million"};
I’m thinking of transferring these to enums separately, so I will have 3 enum classes: digit, teen and anchors with getValue methods implemented. But I don’t want to have them in separate files as I have only small data and same type of data. What is the best way to have all these with access methods in same meaningful java file?
They can be three inner classes like this:
Then refer them
Types.Digits.ONE,Types.Teen.TWENTYetc.You can also use static imports like this:
..
in order to have shorter references:
Digits.ONE,Teen.TWENTYetc.