Use Assertions to Check for unreachable code : assert « Statements « SCJP






public class MainClass{
    public static void main(String[] argv){
        int y = 0;
        switch(y) {
          case 1: y = 3; break;
          case 2: y = 9; break;
          case 3: y = 27; break;
          default: assert false; // we're never supposed to get here!
        }

    }
}








5.13.assert
5.13.1.Assertions give you a way to test your assumptions during development and debugging.
5.13.2.The new assert keyword has the following syntax
5.13.3.Assertion Command-Line Switches
5.13.4.Do Use Assertions to Validate Arguments to a Private Method
5.13.5.Use Assertions to Check for unreachable code