January 2014
Intermediate to advanced
736 pages
70h 43m
English
Line 18 uses Scanner object input’s nextInt method to obtain an integer from the user at the keyboard. At this point the program waits for the user to type the number and press the Enter key to submit the number to the program.
Our program assumes that the user enters a valid integer value. If not, a runtime logic error will occur and the program will terminate. Appendix H discusses how to make your programs more robust by enabling them to handle such errors—this makes your program more fault tolerant.
In line 18, we place the result of the call to method nextInt (an int value) in variable number1 by using the assignment operator, =. The statement is read as “number1 gets the value of input.nextInt().” ...
Read now
Unlock full access