Online Java Compiler By
JavaTpoint.com
import java.lang.annotation.*; //import annotation class of lang package import java.lang.reflect.Method; //import Method class of reflect package import java.util.Arrays; public class ReflectMethodgetParameterAnnotationsExample2 { public void Display(@Displayconf Object config) {} public static void main(String... args) throws NoSuchMethodException { Method mthd = ReflectMethodgetParameterAnnotationsExample2.class.getDeclaredMethod("Display", Object.class); Annotation[][] prm = mthd.getParameterAnnotations(); System.out.println(Arrays.toString(prm)); //print statement } @Target({ElementType.PARAMETER}) //set target element type @Retention(RetentionPolicy.RUNTIME) //retention policy private @interface Displayconf {} }
Output