Using Class Time2’s Overloaded Constructors
Class Time2Test
(Fig. F.6) invokes the overloaded Time2
constructors (lines 8–12 and 40). Line 8 invokes the no-argument constructor (Fig. F.5, lines 12–15). Lines 9–13 of the program demonstrate passing arguments to the other Time2
constructors. Line 9 invokes the single-argument constructor that receives an int
at lines 18–21 of Fig. F.5. Line 10 invokes the two-argument constructor at lines 24–27 of Fig. F.5. Line 11 invokes the three-argument constructor at lines 30–33 of Fig. F.5. Line 12 invokes the single-argument constructor that takes a Time2
at lines 36–40 of Fig. F.5. Next, the application displays the String
representations of each Time2
object to confirm that it was initialized properly. ...
Get Android™ How to Program, Second 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.