Java Reflection - 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 ww. j a  va2  s .  c  om*/
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();

  }
}