Online Java Compiler By
JavaTpoint.com
//import statement import java.lang.reflect.Method; public class ReflectMethodgetParameterTypesExample1 { public static void proc(int i, String s, String... args) {} //static method proc public static void main(String... args) throws NoSuchMethodException { //main method Method mthd = ReflectMethodgetParameterTypesExample1.class.getDeclaredMethod("proc", int.class, String.class, String[].class); Class[] cls= mthd.getParameterTypes(); for (int i = 0; i < cls.length; i++) { //loop from i to length of array containing parameter types System.out.println(cls[i]); } } }
Output