package reflection05;

import java.lang.reflect.Constructor;
import java.util.ArrayList;

/**
 * Ermitteln aller oder eines bestimmten Konstruktors.
 * 
 * @author  Ralf Kunze (rkunze@uos.de), Institut fuer Informatik, Universitaet Osnabrueck
 * @date 02.06.2007
 */
public class ConstructorTest {

    public static void main(String[] args) {
        Class<ArrayList> arrayListClass = ArrayList.class;
        

        System.out.println("Alle Konstruktoren der Klasse ArrayList");
        for(Constructor c: arrayListClass.getConstructors()) {
            System.out.println("\t" + c);
        }
        
        Constructor<ArrayList> c = null;
        
        System.out.println("Ausgewaehlte Konstruktoren der Klasse ArrayList");
        try {
            c = arrayListClass.getConstructor();
            System.out.println("\t" + c);
            c = arrayListClass.getConstructor(int.class);
            System.out.println("\t" + c);
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            System.err.println("Konstruktor konnte nicht gefunden werden");
        }
        
       
    }

}
