Section 3.2.2 AccountTest Class That Creates and Uses an Object of Class Account

• A class that creates an object of another class, then calls the object’s methods, is a driver class.

Scanner method nextLine (p. 75) reads characters until a newline character is encountered, then returns the characters as a String.

Scanner method next (p. 75) reads characters until any white-space character is encountered, then returns the characters as a String.

• A class instance creation expression (p. 75) begins with keyword new and creates a new object.

• A constructor is similar to a method but is called implicitly by the new operator to initialize an object’s instance variables at the time the object is created.

• To call a method of an object, follow ...

Get Java™ How To Program (Early Objects), Tenth Edition 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.