1  import java.awt.Rectangle;
  2  
  3  /**
  4     This example demonstrates constructors.
  5  */
  6  public class ConstructorDemo
  7  {
  8     public static void main(String[] args)
  9     {
 10        // Constructs and prints a rectangle
 11        System.out.println(new Rectangle(5, 10, 20, 30));
 12  
 13        // Constructs a rectangle and saves it in a variable
 14        Rectangle box = new Rectangle(5, 10, 20, 30);
 15        System.out.print("box: ");
 16        System.out.println(box);
 17  
 18        // The constructor with no arguments
 19        box = new Rectangle();
 20        System.out.print("box: ");
 21        System.out.println(box);
 22     }
 23  }