Constructor isVarArgs() method in Java with Examples Last Updated : 18 Apr, 2023 Comments Improve Suggest changes Like Article Like Report 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 approach to pass arguments than array when it is not known how many arguments to pass in the constructor. Syntax: public boolean isVarArgs() Parameters: This method accepts nothing. Return: This method returns true if and only if this executable was declared to take a variable number of arguments. Below programs illustrate isVarArgs() method: Program 1: Java // Java program to illustrate isVarArgs() method import java.lang.annotation.Annotation; import java.lang.reflect.Constructor; public class GFG { public static void main(String[] args) { // create a class object Class classObj = shape.class; // get Constructor object // array from class object Constructor[] cons = classObj.getConstructors(); // check isVarArgs or not boolean isVargs = cons[0].isVarArgs(); // print result System.out.println("isVargs : " + isVargs); } public class shape { public shape(Object... objects) { } } } Output:isVargs : true Program 2: Java // Java program to illustrate isVarArgs() method import java.lang.annotation.Annotation; 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(); for (int i = 0; i < cons.length; i++) { // check isVarArgs or not boolean isVargs = cons[i].isVarArgs(); // print result System.out.println(cons[i]); System.out.println("isVargs : " + isVargs); } } } Output: public java.lang.String(byte[], int, int) isVargs : false public java.lang.String(byte[], java.nio.charset.Charset) isVargs : false public java.lang.String(byte[], java.lang.String) throws java.io.UnsupportedEncodingException isVargs : false public java.lang.String(byte[], int, int, java.nio.charset.Charset) isVargs : false public java.lang.String(byte[], int, int, java.lang.String) throws java.io.UnsupportedEncodingException isVargs : false public java.lang.String(java.lang.StringBuilder) isVargs : false public java.lang.String(java.lang.StringBuffer) isVargs : false public java.lang.String(byte[]) isVargs : false public java.lang.String(int[], int, int) isVargs : false public java.lang.String() isVargs : false public java.lang.String(char[]) isVargs : false public java.lang.String(java.lang.String) isVargs : false public java.lang.String(char[], int, int) isVargs : false public java.lang.String(byte[], int) isVargs : false public java.lang.String(byte[], int, int, int) isVargs : false References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#isVarArgs() Comment More infoAdvertise with us Next Article Constructor isVarArgs() 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 isSynthetic() method in Java with Examples The isSynthetic() method of java.lang.reflect.Constructor class is used to return the boolean value true if this constructor object is a synthetic construct else method returns false showing this construct is not a synthetic construct. As we know Synthetic Constructs are Class, Fields, and Methods t 3 min read Constructor equals() method in Java with Examples The constructor class provides information about a single constructor for a class and it also provides access to that constructor. The equals() method of java.lang.reflect.Constructor is used to compare this Constructor against the passed object. If the objects are the same then the method returns t 2 min read Class isArray() method in Java with Examples The isArray() method of java.lang.Class class is used to check if this Class is the Array class. The method returns true if this Class is the Array class. It returns false otherwise.Syntax: public boolean isArray() Parameter: This method does not accept any parameter.Return Value: This method return 1 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 newInstance() method in Java with Examples The newInstance() method of a Constructor class is used to create and initialize a new instance of this constructor, with the initialization parameters passed as parameter to this method. Each parameter is unwrapped to match primitive formal parameters, and both primitive and reference parameters ar 3 min read Like