Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Constructor;

public class Main {

    public static void main(String[] args) throws Exception {

        MyClass cls = new MyClass();
        Class c = cls.getClass();

        // constructor with arguments as Double and Long
        Class[] cArg = new Class[2];
        cArg[0] = Double.class;
        cArg[1] = Long.class;
        Constructor ct = c.getDeclaredConstructor(cArg);
        System.out.println("Constructor = " + ct.toString());

    }
}

class MyClass {
    MyClass() {
        System.out.println("no argument constructor");
    }

    public MyClass(Double d, Long l) {
        this.d = d;
        this.l = l;
    }

    Double d = new Double(3.4d);
    Long l = new Long(123);
}