Suppose you have a "simple" enumeration:
public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }
And then you use it somewhere:
Day day = Day.SUNDAY; ... if(day==Day.SUNDAY) {...}
How does this compare performance (memory and time) using ints?
int day = Day.SUNDAY; ... public class Day { public static final int SUNDAY=0; public static final int MONDAY=1; }
We have included the JIT HotSpot compiler along with other "standard" optimizations.
source share