3.5. Constructors of a class
[6.3] Create and overload constructors; including impact on default constructors
In this section, you’ll create constructors, learn the differences between default and user-defined constructors, and create overloaded constructors.
What happens when you open a new bank account? Depending on the services your bank provides, you may be assigned a new bank account number, provided with a checkbook, and given access to a new online account the bank has created for you. These details are created and returned to you as part of setting up your new bank account.
Compare these steps with what a constructor does in Java, as illustrated in figure 3.18.
Figure 3.18. The series of steps that may be executed ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.