title: Missing return statement with switch
body: <pre><code>public AlertStatus nextStatus(){
      int randNum = randNumGen.nextInt(3);
      switch(randNum){
          case 0: return new AlertStatusGreen();
          case 1: return new AlertStatusYellow();
          case 2: return new AlertStatusRed();
          default: System.out.println("ERROR: no random number.");
      }
  }
  </code></pre>
  
  <p>This is a method in one of the classes for a program I have to make for school.
  The switch takes a random integer and uses it to return an object of a certain class that is derived from the class AlertStatus.</p>
  
  <p>For some reason I keep getting an error saying "missing return statement }" for line 9 of the above block of code (the very last line in the above code). I don't understand why it's saying this though seeing as I already have return statements for each case.</p>