Method startFibonacci for Performing and Timing Fibonacci Calculations
Method startFibonacci
(lines 59–70) is called several times in main
(lines 29, 30, 39 and 41) to initiate Fibonacci calculations and to calculate the time each calculation requires. The method receives the Fibonacci number to calculate and performs the following tasks:
• Line 62 creates a TimeData
object to store the calculation’s start and end times.
• Line 64 displays the Fibonacci number to be calculated.
• Line 65 stores the current time before method fibonacci
is called.
• Line 66 calls method fibonacci
to perform the calculation.
• Line 67 stores the current time after the call to fibonacci
completes.
• Line 68 displays the result and the total time required for the ...
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.