Online Java Compiler By
JavaTpoint.com
import java.lang.reflect.Method; public class ReflectMethodgetParameterTypesExample2 { public static void method1(int x , int y , double z , String str) {} //static method method1 public static void main(String... args) throws NoSuchMethodException { Method mthd = ReflectMethodgetParameterTypesExample2.class.getDeclaredMethod("method1", int.class, int.class, double.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