Mega Code Archive

 
Categories / Java Book / 008 Reflection
 

0443 String representation of the contructor

String toGenericString() Returns a string describing this Constructor, including type parameters. String toString() Returns a string describing this Constructor. Revised from Open JDK source code import java.lang.reflect.Constructor; public class Main { public static void main(String[] argv) throws Exception { Constructor[] constructors = String.class.getDeclaredConstructors(); for (int i = 0; i < constructors.length; i++) { Constructor c = constructors[i]; System.out.println(c.toGenericString()); } } }