Java Constructor.toGenericString()

Syntax

Constructor.toGenericString() has the following syntax.

public String toGenericString()

Example

In the following code shows how to use Constructor.toGenericString() method.


import java.lang.reflect.Constructor;
import java.util.ArrayList;
/*  w  w  w . ja v a  2s  . c om*/
public class Main {
  public static void main(String[] argv) throws Exception {
      Constructor[] constructors = ArrayList.class.getDeclaredConstructors();

      for (int i = 0; i < constructors.length; i++) {
        Constructor c = constructors[i];
        System.out.println(c.toGenericString());
      }
    }
  
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang.reflect »




Array
Constructor
Field
Method
Modifier
ParameterizedType
TypeVariable