September 2011
Beginner
650 pages
15h 47m
English
In the preceding example, a parameter-less constructor was used. Although this is fine for some situations, most often you will need a constructor that accepts one or more parameters. Parameters are added to a constructor in the same way that they are added to a method: just declare them inside the parentheses after the constructor’s name. For example, here, MyClass is given a parameterized constructor:

The output from this program is shown here:
![]()
In this version of the program, the MyClass( ) constructor defines one parameter ...
Read now
Unlock full access