Can static methods that return a value throw an exception?
<p>I have a static method that returns a String, but in the event that the string that is passed in does not match one of several words, I want to throw an exception. The code below is just a sample of what I am trying to do, but I keep getting "non static variable this cannot be referenced from a static context" message on the line where I throw the exception. Basically, the return value from getMsg has to be valid, or the program cannot proceed, so I need a way to catch this.</p>

<pre><code>public static String getMsg(String input) throws UnknownInputException{
      if (input.equals("A")){
           return "key for A";
      }
      throw new UnknownInputException("Some Message");
      return "unknownInput";
</code></pre>
