11.3. Overloading ConstructorsWe can overload constructors, just as we overloaded methods. The parameter lists must be different. This can mean that they take a different number of parameters and/or that the types are different. In the above code we have two constructors. One takes no parameters, and one takes a String object, which is the name to use. Here we have added another constructor that takes the name and an array of grades. Program 99. Student Class with Three Constructors
To use this constructor we need to pass in a name as a String object and an array of grades of the type double. |