Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import static java.lang.System.out;

public class Main {
    private static final String fmt = "%24s: %s%n";

    <E extends RuntimeException> void genericThrow() throws E {
    }

    public static void main(String... args) {
        try {
            Class<?> c = Class.forName("Main");
            Method[] allMethods = c.getDeclaredMethods();
            for (Method m : allMethods) {
                Class<?>[] pType = m.getParameterTypes();
                Type[] gpType = m.getGenericParameterTypes();
                for (int i = 0; i < pType.length; i++) {
                    out.format(fmt, "ParameterType", pType[i]);
                    out.format(fmt, "GenericParameterType", gpType[i]);
                }
            }
        } catch (ClassNotFoundException x) {
            x.printStackTrace();
        }
    }
}