I have a problem regarding how can I put an integer value as well as a string in an enum class. I'm using the values of the enum to be stored in the database. What I want is something like this
public enum MyList {
1,
2,
3,
APPLE,
BANANA
}
but i have an error in the value '1', it says
Syntax error on token "1", Identifier expected
I've searched for answers here but what I've found is they try to get the value of the enum based on the input integer from the user. What I need is to directly store the values 1
,2
, 3
, APPLE
and BANANA
in the database.
Is it even possible to combine an integer and a string in an enum? Any help or suggestions would be a great help. Thanks a lot!
PS. I'm very new to programming, so it's quite hard for me to explain the problem using the correct terms. Kindly reply using simple terms! Thank you!
EDIT:
If 1
is the only integer at the said class, the error is like what I've said above. But after I added 2
and 3
, it has a red line in public enum MyList {
and says
Syntax error on token(s), misplaced construct(s)