The Java Program: BodyMain4.java

  1 // BodyMain4.java:  explicit constructor invocation
  2 
  3 class Body {
  4    long idNum;
  5    String nameFor;
  6    Body orbits;
  7 
  8    static long nextID = 0;
  9 
 10    Body () {
 11       idNum = nextID++;
 12    }
 13 
 14    Body (String n) {
 15       this (n, null);
 16    }
 17 
 18    Body (String n, Body o) {
 19       this();
 20       nameFor = n;
 21       orbits = o;
 22    }
 23 }
 24 
 25 class BodyMain4  {
 26 
 27    public static void main (String args[])  {
 28 
 29       Body sun   = new Body("Sol");
 30       Body earth = new Body("Earth", sun);
 31 
 32    }
 33 
 34 }