Java: run method based on user input?
<p>say I have three methods </p>

<pre><code>method1()
method2()
method3()
</code></pre>

<p>and I have the user input a number corresponding to which method they want to run, is there a way to run it directly from their input? i.e. instead of having an if statement along the lines of</p>

<pre><code>System.out.println("Which method would you like to run? 1/2/3");
String input = reader.readLine();
if(input == 1){method1();}
if(input == 2){method2();}
...
</code></pre>

<p>etc. and instead be able to have something like</p>

<pre><code>System.out.println("Which method would you like to run? 1/2/3");
String input = reader.readLine();
method(input)();
</code></pre>

<p>?</p>
