title: How to map String to Java class?
body: <p>I want to map a String into a Java class.
  For example, I want to define my Main class such that it works in the following way:</p>
  
  <pre><code>$ java Main SayHello
  Hello!
  $ java Main SayBye
  Bye!
  $ java Main SayHola
  Error: No such class exists
  </code></pre>
  
  <p>Here is the code.</p>
  
  <pre><code>public class Main {
      public static void main(String[] args) {
          // Call args[0].say()
      }
  }
  
  public class SayHello {
      public static void say() {
          System.out.println("Hello!");
      }
  }
  
  public class SayBye {
      public static void say() {
          System.out.println("Bye!");
      }
  }
  </code></pre>
  
  <p>I know that I could do it by manually mapping each possible value of <code>args[0]</code> to a Java class, for example:</p>
  
  <pre><code>if (args[0].equals("SayHello")) {
      SayHello.say();
  }
  </code></pre>
  
  <p>But is there a way to do this automatically?</p>