previous | start | next

## Enumerating Constructors

- Print the names and parameter types of all `Rectangle`
  constructors:

      for (Constructor c : cons)
      {
         Class[] params = cc.getParameterTypes();
         System.out.print("Rectangle(");
         boolean first = true;
         for (Class p : params)
         {
            if (first) first = false; else System.out.print(", ");
            System.out.print(p.getName());
         }
         System.out.println(")");
      }

- Yields

      Rectangle()
      Rectangle(java.awt.Rectangle)
      Rectangle(int, int, int, int)
      Rectangle(int, int)
      Rectangle(java.awt.Point, java.awt.Dimension)
      Rectangle(java.awt.Point)
      Rectangle(java.awt.Dimension)

previous | start | next