Constructor toGenericString() method in Java with Examples Last Updated : 29 Oct, 2019 Comments Improve Suggest changes Like Article Like Report The toGenericString() method of java.lang.reflect.Constructor class is used to return get the generic form of this constructor, i.e. a string representing the details about this constructor including the type parameters. Syntax: public String toGenericString() Parameters: This method accepts nothing. Return: This method returns a generic form of this constructor as a string that describes this Constructor along with the type parameters. Below programs illustrate toGenericString() method: Program 1: Java // Java program to illustrate // toGenericString() 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 get string representation String str = cons[0].toGenericString(); // print result System.out.println("Constructor : " + str); } public class shape { public shape(Object... objects) { } } } Output: Constructor : public GFG$shape(GFG, java.lang.Object...) Program 2: Java // Java program to illustrate // toGenericString() 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++) { String str = cons[i].toGenericString(); // print result System.out.println(str); } } } Output: public java.lang.String(byte[], int, int) public java.lang.String(byte[], java.nio.charset.Charset) public java.lang.String(byte[], java.lang.String) throws java.io.UnsupportedEncodingException public java.lang.String(byte[], int, int, java.nio.charset.Charset) public java.lang.String(byte[], int, int, java.lang.String) throws java.io.UnsupportedEncodingException public java.lang.String(java.lang.StringBuilder) public java.lang.String(java.lang.StringBuffer) public java.lang.String(byte[]) public java.lang.String(int[], int, int) public java.lang.String() public java.lang.String(char[]) public java.lang.String(java.lang.String) public java.lang.String(char[], int, int) public java.lang.String(byte[], int) public java.lang.String(byte[], int, int, int) References: https://docs.oracle.com/javase/10/docs/api/java/lang/reflect/Constructor.html#toGenericString() Comment More infoAdvertise with us Next Article Constructor toGenericString() 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 toString() method in Java with Examples The toString() method of java.lang.reflect.Constructor class is used to return string representation of this Constructor.This string is the collection of all the properties of this constructor. For creating this string method adds access modifiers of the constructor with the name of the declaring cl 2 min read Class toGenericString() method in Java with Examples The toGenericString() method of java.lang.Class class is used to convert the instance of this Class to a string representation along with the information about the modifiers and type parameters. This method returns the formed string representation. Syntax: public String toGenericString() Parameter: 2 min read Field toGenericString() method in Java with Examples The toGenericString() method of java.lang.reflect.Field is used to return a string which represents this Field, including its generic type. The format of the string is the access modifiers for the field, if any, followed by the generic field type, followed by a space, followed by the fully-qualified 2 min read Class toString() method in Java with Examples The toString() method of java.lang.Class class is used to convert the instance of this Class to a string representation. This method returns the formed string representation. Syntax: public String toString() Parameter: This method does not accept any parameter. Return Value: This method returns the 1 min read AbstractSet toString() method in Java with Example The toString() method of Java AbstractSet is used to return a string representation of the elements of the Collection. The String representation comprises a set representation of the elements of the Collection in the order they are picked by the iterator closed in square brackets[].This method is us 2 min read Like