title: How to call a method stored in a HashMap? (Java)
body: <p>I have a list of commands (i, h, t, etc) that the user will be entering on a command line/terminal Java program. I would like to store a hash of command/method pairs:</p>
  
  <pre><code>'h', showHelp()
  't', teleport()
  </code></pre>
  
  <p>So that I can have code something like:</p>
  
  <pre><code>HashMap cmdList = new HashMap();
  
  cmdList.put('h', showHelp());
  if(!cmdList.containsKey('h'))
      System.out.print("No such command.")
  else
     cmdList.getValue('h')   // This should run showHelp().
  </code></pre>
  
  <p>Is this possible? If not, what is an easy way to this?</p>