8.17 Wrap-Up

In this chapter, we presented additional class concepts. The Time class case study showed a complete class declaration consisting of private data, overloaded public constructors for initialization flexibility, set and get methods for manipulating the class’s data, and methods that returned String representations of a Time object in two different formats. You also learned that every class can declare a toString method that returns a String representation of an object of the class and that method toString can be called implicitly whenever an object of a class appears in the code where a String is expected. We showed how to throw an exception to indicate that a problem has occurred.

You learned that the this reference is used implicitly ...

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.