Constructor getParameterAnnotations() method in Java with Examples Last Updated : 27 Nov, 2019 Comments Improve Suggest changes Like Article Like Report The getParameterAnnotations() method of a Constructor class is used to get a two-dimensional Annotation array that represent the annotations on the formal parameters of this Constructor. If the Constructor contains no parameters, an empty array will be returned. If the Constructor contains one or more parameters then a two-dimension Annotation array will be returned. A nested array of this two-dimension array will be empty for the parameter with no annotations. The objects of annotation returned by this method are serializable. The array of arrays returned by this method can be easily modified. Syntax: public Annotation[][] getParameterAnnotations() Parameters: This method accepts nothing. Return value: This method returns an array of arrays that represent the annotations on the formal and implicit parameters, in declaration order, of the executable represented by this object. Below programs illustrate the getParameterAnnotations() method: Program 1: Java // Java program to demonstrate // Constructor.getParameterAnnotations() method import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Constructor; import java.util.Arrays; public class GFG { public static void main(String... args) throws NoSuchMethodException { // Create Constructor Object Constructor[] constructors = Test.class.getConstructors(); // get Annotation array Annotation[][] annotations = constructors[0].getParameterAnnotations(); System.out.println("Parameter annotations -->"); System.out.println(Arrays.deepToString(annotations)); } } class Test { public Test(@Properties Object config) { } } @Retention(RetentionPolicy.RUNTIME) @interface Properties { } Output: Parameter annotations --> [[@Properties()]] Program 2: Java // Java program to demonstrate // Constructor.getParameterAnnotations() method import java.lang.annotation.Annotation; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.reflect.Constructor; public class GFG { public static void main(String... args) throws NoSuchMethodException { // Create Constructor Object Constructor[] constructors = GfgDemo.class.getConstructors(); // get Annotation array Annotation[][] annotations = constructors[0].getParameterAnnotations(); System.out.println("Parameter annotations -->"); for (Annotation[] ann : annotations) { for (Annotation annotation : ann) { System.out.println(annotation); } } } } class GfgDemo { public GfgDemo(@Path Path path) { } } @Retention(RetentionPolicy.RUNTIME) @interface Path { } Output: Parameter annotations --> @Path() References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#getParameterAnnotations() Comment More infoAdvertise with us Next Article Constructor getParameterAnnotations() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Constructors Java-Functions java-lang-reflect-package Practice Tags : Java Similar Reads Constructor getAnnotation() method in Java with Examples The getAnnotation() method of a Constructor class is used to get this constructor object annotation for the specified type if such an annotation is present, else null. Specified type is passed as parameter. Syntax: public <T extends Annotation> T getAnnotation(Class<T> annotationClass) P 2 min read Constructor getDeclaredAnnotations() method in Java with Examples The getDeclaredAnnotations() method of java.lang.reflect.Constructor class is used to return annotations present on this Constructor element as an array of Annotation class objects. The getDeclaredAnnotations() method ignores inherited annotations on this constructor object.Returned array can contai 2 min read Constructor getParameterCount() method in Java with Examples The getParameterCount() method of java.lang.reflect.Constructor class is used to return the number of parameters present on this constructor object. Every constructor contains a number of parameters starting from zero to many. This method is helpful to get those numbers of parameters. Syntax: public 2 min read Constructor getTypeParameters() method in Java with Examples The getTypeParameters() method of a Constructor class is used to get an array of TypeVariable objects declared by this Constructor Object, in declaration order. Elements of array represent the type variables objects declared by Method. An array of length 0 is returned by this getTypeParameters(), if 2 min read Constructor getGenericParameterTypes() method in Java with Examples The getGenericParameterTypes() method of java.lang.reflect.Constructor class is used to return an array of objects that represent the types of the parameters present on this constructor object. The arrangement Order of the returned array from this method is the same as the order of parameter present 2 min read Like