title: Java Supplier/Consumer/Runnable? How to invoke method when it is supplied as a a string argument
body: <p>I need a help. User supplying method with its arguments as a string. My code need to run this method.</p>
  
  <p>How we can we achieve this using Supplier/Consumer/Runnable. This can be done using reflection but I want to avoid it.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class InvokeStringArgument{
      public static Supplier&lt;String&gt; invokeMe(String returnStr){
          return new Supplier&lt;String&gt;(){
              public String get(){
                  System.out.println("Success");
                  return returnStr;
              }
          };
      }
  
      public static void main(String[] args){
          //invokeMe("MyValue").get();
  
          System.out.println("Please enter method to invoke:");
          Scanner sc = new Scanner(System.in);
          String methodName = sc.next();
          //Need a code which will run the method when passed as a string
          //For example user input it as invokeMe("MyValue")
      }
  }
  </code></pre>