Getting a list of the public constructors of a class through reflection

Call getConstructors on a Class object. There is another method called getDeclaredConstructors but this one returns all constructors, including the private and protected ones.

import java.lang.reflect.*;
public class Main {
   public static void main(String args[]) throws Exception {
      Class c = Class.forName("MyClass");   // or Class c = MyClass.getClass();
      Constructor[] constructors = c.getConstructors();
      for (int i=0; i<constructors.length; i++) {
class MyClass
   public MyClass() { }
   public MyClass(int a) { }
   protected MyClass(float f) { }
   private MyClass(String s) { }


public MyClass()
public MyClass(int)