title: creating instance of object using reflection , when the constructor takes an array of strings as argument
body: <p>I am trying to create an instance of a class which has only the following constructor, overwriting the default constructor</p>
  
  <pre><code>public HelloWorld(String[] args)
  </code></pre>
  
  <p>I am doing the following</p>
  
  <pre><code>Class reflect;
  HelloWorld obj = null;
  //some logic to generate the class name with full path
  reflect = Class.forName(class_name);
  </code></pre>
  
  <p>Then I am trying to create an object for this class</p>
  
  <pre><code> obj = (HelloWorld)reflect.getConstructor(String[].class)
                            .newInstance(job1.arg_arr());
  </code></pre>
  
  <p><code>arg_arr()</code> is for converting a list to an array of strings</p>
  
  <pre><code>public String[] arg_arr(){
      String arg_list[]=new String[args.size()];
      return args.toArray(arg_list);
  }
  </code></pre>
  
  <p>I get the following stack trace when trying to create the instance
  <code>java.lang.IllegalArgumentException</code>: </p>
  
  <pre><code>wrong number of arguments
  
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)  
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)  
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)  
  at java.lang.reflect.Constructor.newInstance(Constructor.java:408)  
  at processmigration.Process_manager.eval(Process_manager.java:175)  
  at processmigration.Process_manager.run(Process_manager.java:147)  
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>I wonder what is going wrong since I am passing only one argument to newInstance() just like the constructor of the class I am trying to create.</p>