Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.lang.reflect.*;
  2.  
  3. public class constructor2 {
  4.     public constructor2() {
  5.     }
  6.  
  7.     public constructor2(int a, int b) {
  8.         System.out.println("a = " + a + " b = " + b);
  9.     }
  10.  
  11.     public static void main(String args[]) {
  12.         try {
  13.             Class cls = Class.forName("constructor2");
  14.             Class partypes[] = new Class[2];
  15.             partypes[0] = Integer.TYPE;
  16.             partypes[1] = Integer.TYPE;
  17.             Constructor ct = cls.getConstructor(partypes);
  18.             Object arglist[] = new Object[2];
  19.             arglist[0] = new Integer(37);
  20.             arglist[1] = new Integer(47);
  21.             Object retobj = ct.newInstance(arglist);
  22.         } catch (Throwable e) {
  23.             System.err.println(e);
  24.         }
  25.     }
  26. }