7.9. Putting Things Together

In this section, we simply write an example program that demonstrates many of the concepts we have discussed in this chapter. This example is a modified version of an example written by Sun, called Clock. A Clock object is created, which has hour, minute, and second values. A method displays the current time once the Clock is created using either its default no-arg constructor or another constructor that defines a custom time setting. When the Clock object's tick() method is called, the second value increments by one, possibly changing the hour and minute values on the clock. We need two listings for this example—one that creates the Clocks, holds their values, and defines their methods, and another that instantiates ...

Get Java™ for ColdFusion® Developers 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.