Suppose you have an enumeration with three values:
enum Colors { RED, GREEN, BLUE }
You switch all the values in a method, thinking that you have handled all the cases:
switch (colors) {
case RED: ...
case GREEN: ...
case BLUE: ...
}
Then you add the new value to the enumeration:
enum Colors { RED, GREEN, BLUE, YELLOW }
And everything still compiles fine, except that you silently skip the case for YELLOWin method. Is there a way to raise a compile-time error in such a scenario?
: , Java. "", , , , , / ,