April 2019
Intermediate to advanced
360 pages
9h 17m
English
To demonstrate the tail call functional design pattern, we will implement a Lucky 7 application consisting of a single TailCallExample class. This class will prompt the user for a number and perform multiple mathematical on the number that will result in 7, regardless of the input.
The first section of code starts with the import statement. We will use the Scanner class to obtain user input from the console window. The following code also contains theInitialNumber, an int class variable. Next is the first section of the main() method, which simply prompts the user for input and stores the result in the theInitialNumber class variable. This value will be used throughout our application:
import java.util.Scanner; ...Read now
Unlock full access