Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Constructor;
import java.lang.reflect.Member;

public class Main {
    public static void main(String[] args) throws ClassNotFoundException {
        Class c = Class.forName("java.lang.String");

        Constructor[] constructors = c.getDeclaredConstructors();
        for (int i = 0; i < constructors.length; i++) {
            print_method_or_constructor(constructors[i]);
        }

    }

    public static void print_method_or_constructor(Member member) {
        Constructor c = (Constructor) member;
        Class[] parameters = c.getParameterTypes();
        Class[] exceptions = c.getExceptionTypes();
        System.out.println(c.getDeclaringClass());

        for (int i = 0; i < parameters.length; i++) {
            System.out.println(parameters[i]);
        }
        for (int i = 0; i < exceptions.length; i++) {
            System.out.println(exceptions[i]);
        }
    }
}