The complete constructor is seen below.
public class Cone
{
// instance variables
private double radius; // radius of the base
private double height; // height of the cone
// constructor
public Cone( double rad, double hei )
{
radius = rad;
height = hei;
}
// methods
}
The constructor copies values from its parameters to the instance variables of the new object. The scope of the parameters is just the constructor. They are not visible outside of the constructor.
Think of a parameter as a scrap of paper containing information handed to the constructor. The constructor copies the information to the instance variables which can be seen by the other methods.
The names for the constructor's parameters are awkward. What can be done about this?