September 2019
Intermediate to advanced
816 pages
18h 47m
English
Having a method, we can inspect the annotations of its parameters by calling getParameterAnnotations():

This method returns a matrix (array of arrays) containing the annotations on the formal parameters, in declaration order:
Class<Melon> clazz = Melon.class;Method methodSlice = clazz.getDeclaredMethod("slice", int.class);Annotation[][] paramAnnotations = methodSlice.getParameterAnnotations();
Fetching each parameter type with its annotations (in this case, we have an int parameter with two annotations) can be accomplished via getParameterTypes(). Since this method maintains the declaration ...