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 {
        Class clazz = String.class;

        Constructor[] constructors = clazz.getDeclaredConstructors();
        for (Constructor constructor : constructors) {
            String name = constructor.getName();
            System.out.println("Constructor name= " + name);

            Class[] paramterTypes = constructor.getParameterTypes();
            for (Class c : paramterTypes) {
                System.out.println("Param type name = " + c.getName());
            }
        }

        Constructor constructor = String.class.getConstructor(new Class[] { String.class });
        System.out.println("Constructor     = " + constructor.getName());
    }
}