Online Java Compiler By
JavaTpoint.com
//import statement import java.lang.reflect.Method; //import method class of reflect import java.lang.reflect.TypeVariable; public class ReflectMethodgetTypeParametersExample1
{
T ThrowX(T t) throws E { return t; } public static void main(String... args) { try { Class> c = Class.forName("ReflectMethodgetTypeParametersExample1"); Method[] mthd = c.getDeclaredMethods(); for (Method m : mthd) { TypeVariable[] tp = m.getTypeParameters(); for(TypeVariable t:tp){ System.out.println(tp); } } } catch (ClassNotFoundException x) { x.printStackTrace(); } } }
Output