Java Constructor .getParameterAnnotations ()
Syntax
Constructor.getParameterAnnotations() has the following syntax.
public Annotation [][] getParameterAnnotations()
Example
In the following code shows how to use Constructor.getParameterAnnotations() method.
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Member;
//from w w w .j a va 2 s . c o m
public class Main {
public static void main(String[] args) throws ClassNotFoundException {
Class c = Class.forName("java.util.List");
Constructor[] constructors = c.getDeclaredConstructors();
for (int i = 0; i < constructors.length; i++) {
print_method_or_constructor(constructors[i]);
}
}
public static void print_method_or_constructor(Member member) {
Constructor c = (Constructor) member;
Annotation[][] annos= c.getParameterAnnotations();
}
}