Calling a Constructor From a Constructor : Constructor « Class Definition « Java Tutorial






class Sphere {
  int radius = 0;

  double xCenter;

  double yCenter;

  double zCenter;

  Sphere() {
    radius = 1;
  }

  Sphere(double x, double y, double z) {
    this();
    xCenter = x;
    yCenter = y;
    zCenter = z;
  }

  Sphere(int theRadius, double x, double y, double z) {
    this(x, y, z);
    radius = theRadius;
  }
}








5.2.Constructor
5.2.1.Using Constructors
5.2.2.The Default Constructor
5.2.3.Multiple Constructors
5.2.4.Calling a Constructor From a Constructor
5.2.5.Duplicating Objects using a Constructor
5.2.6.Class Initializer: during declaration
5.2.7.Order of constructor calls