So you find yourself calling
or alternatively use an immutable
values()
lots in your code. Since this allocates a new array every time and this does not get optimized away, you might want to create a local copy, or an immutable collection and use that instead:public enum Day {
MONDAY, TUESDAY;
private static final Day[] values = values();
...
}
or alternatively use an immutable
Set
.
0 comments:
Post a Comment