Constructor getParameterCount() method in Java with Examples Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report 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 int getParameterCount() Parameters: This method accepts nothing. Return: This method returns the number of formal parameters for the executable this object represents. Below programs illustrate getParameterCount() method: Program 1: Java // Java program to illustrate getParameterCount() method import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) { // create a class object Class classObj = String.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); // get count of parameter int params = cons[0].getParameterCount(); // print parameter count System.out.println("No of Parameters: " + params); } } Output: No of Parameters: 3 Program 2: Java // Java program to illustrate getParameterCount() method import java.lang.reflect.Constructor; import java.util.ArrayList; public class GFG { public static void main(String[] args) { // create a class object Class classObj = ArrayList.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); for (int i = 0; i < cons.length; i++) { // get count of parameter int params = cons[i].getParameterCount(); // print parameter count System.out.println( cons[i].toGenericString() + "-> parameter count = " + params); } } } Output: public java.util.ArrayList(java.util.Collection)-> parameter count = 1 public java.util.ArrayList()-> parameter count = 0 public java.util.ArrayList(int)-> parameter count = 1 References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#getParameterCount() Comment More infoAdvertise with us Next Article Constructor getParameterCount() 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 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 getParameterAnnotations() method in Java with Examples 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 mo 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 Class getTypeParameters() method in Java with Examples The getTypeParameters() method of java.lang.Class class is used to get the type parameters of this entity. This entity can be a class, an array, an interface, etc. The method returns an array of TypeVariable objects representing the type variables.Syntax: public TypeVariable<Class<T>> ge 2 min read Constructor isVarArgs() method in Java with Examples The isVarArgs() method of java.lang.reflect.Constructor class is used to return the boolean value true if this Constructor can take a variable number of arguments as parameters else method will return false.VarArgs allows the constructor to accept a number of arguments. using VarArgs is a better app 2 min read Like