I have an object that has an enum field. I want to change it, by refering to the enum value(int).
So i have this enum class:
Day{
MONDAY(1),
TUESDAY(2),
WEDNESDAY(3),
THURSDAY(4),
FRIDAY(5)
}
I have a Date class, which has one field: Day day; (it has some other fields like hour and minute, but thats irrelevant regarding this question). I created a Date object:
Date myDate = new Date(Day.Monday...);
Lets say, that a condition happens, where i want to change myDate's Day field to Tuesday.
Can i do that by refering the int value of the enum?
So i would like to have something like this:
myDate.day = day.getValue() +1;
I know this wouldnt work because it would result in an int or Integer, but the point is that i want to jump to the "next" day by incrementing a value. So, can i assign an enum to a field by refering to its value?