title: Java uncovered switch statements in a method. Does the method need to return something?
body: <p>I'm reading some Java textbooks trying to learn a new language and I came across this method.</p>
  
  <pre><code>private String monthName (int month) { // bad example since this method needs to return a String
    switch (month) {
    case 1:
        return "January";
    case 2:
        return "February";
    ...
  
    case 12:
        return "December";
    }
  }
  </code></pre>
  
  <p>The statement following this code says:</p>
  
  <blockquote>
    <p>The compiler will reject this code because it is possible to reach the
    end with- out returning a value.</p>
  </blockquote>
  
  <p>So in Java, I assume that if a method has the word "String" before the method name, it <strong>MUST</strong> return a String? The problem with this switch statement is that perhaps no case statement condition is satisfied and execution just drops out of the bottom? Is it necessary for methods that are not labeled to void to <strong>ALWAYS</strong> return a value?</p>