An example of statements invoking the deposit and withdraw methods of the Account class is
fredsAccount, deposit (100) ;
amountLeft = fredsAccount.withdraw(120) ;
where amountLeft is a variable of type double.
4.3 Constructors
Java provides a special kind of method, called a constructor, that executes each time an
instance of an object is created. The constructor can be used to initialize the state of an object.
The call to
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.