title: Parametrized Private Constructor using Reflection
body: <p>How to access parametrized constructor using Reflection API. I have been trying to do it with the following set of class but it throws some error.</p>
  
  <pre><code>    //Primary class
      package com.deepak;
  
      public class A {
      private String name;
  
       private A(String name) {
              this.name = name;
          }
  
      }
  
  //Exact class
  
      class MethodCall {
  
       Class first = Class.forName("com.deepak.A");
              Constructor constructor1 = first.getDeclaredConstructor();
              constructor1.setAccessible(true);
             A a= (A) constructor1.newInstance("deepak");
              System.out.println(a);
  
  
      }
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoSuchMethodException: com.deepak.A.&lt;init&gt;()
      at java.lang.Class.getConstructor0(Class.java:3082)
      at java.lang.Class.getDeclaredConstructor(Class.java:2178)
      at com.deepak.MethodCall.main(MethodCall.java:44)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  </code></pre>