Summary
In this chapter, we have explored the basic components of a class. Once we reviewed how we assembled the CompoundInterest04
example, we broke the program apart and created classes to hold the data, display a user interface, and calculate the result. We also learned about the constructor and the deprecated finalize
methods. We gained insight into what new
does and how the JVM manages a program’s memory.
The second version, CompoundInterest05
, presents how a program is organized professionally based on functionality. It kept separate the data, the user interface, and the action, usually called the business. To gather user input, we had our first look at the Java library Scanner
class. You should now have a good understanding of how a Java class is organized and how you can control access to members of the class.
In the next chapter, we will look more closely at the methods that carry out the actions of a class and how we manage the relationships between classes.
...