title: Want to pass class.getmethod arguments dynamically in run time java
body: <p>I want to invoke a method from by giving methodName in runtime. I can do it in below way.</p>
  
  <pre><code>Method method = MyObject.class.getMethod("doSomething", String.class);
  Object returnValue = method.invoke(null, "parameter-value1");
  </code></pre>
  
  <p>But I want to list down all the overloaded methods with that method name and the different set of arguments and let the user choose a particular overloaded method and dynamically pass those arguments in </p>
  
  <pre><code>Method method = MyObject.class.getMethod("doSomething", String.class);
  </code></pre>
  
  <p>instead of hardcoding <code>String.class</code>.</p>
  
  <p>suppose I have two methods like</p>
  
  <pre><code>methodName(String) 
  </code></pre>
  
  <p>and overloaded method</p>
  
  <pre><code>methodName(String, int)
  </code></pre>
  
  <p>I want to let the user choose which one to pick in runtime and pass that information for <code>getMethod</code> function for that particular method.</p>
  
  <p>How can I do this?</p>