title: Why does Java have an "unreachable statement" compiler error?
body: <p>I often find when debugging a program it is convenient, (although arguably bad practice) to insert a return statement inside a block of code. I might try something like this in Java ....</p>
  
  <pre><code>class Test {
          public static void main(String args[]) {
                  System.out.println("hello world");
                  return;
                  System.out.println("i think this line might cause a problem");
          }
  }
  </code></pre>
  
  <p>of course, this would yield the compiler error.</p>
  
  <blockquote>
    <p>Test.java:7: unreachable statement</p>
  </blockquote>
  
  <p>I could understand why a warning might be justified as having unused code is bad practice. But I don't understand why this needs to generate an error. </p>
  
  <p>Is this just Java trying to be a Nanny, or is there a good reason to make this a compiler error?</p>