Java Reference
In-Depth Information
CHAPTER SUMMARY
1.
A while statement executes a block of code repeatedly. A condition controls
how often the loop is executed.
2.
An off-by-one error is a common error when programming loops. Think
through simple test cases to avoid this type of error.
3.
You use a for loop when a variable runs from a starting to an ending value
with a constant increment or decrement.
4.
Loops can be nested. A typical example of nested loops is printing a table with
rows and columns.
5.
Sometimes, the termination condition of a loop can only be evaluated in the
middle of a loop. You can introduce a Boolean variable to control such a loop.
6.
Make a choice between symmetric and asymmetric loop bounds.
7.
Count the number of iterations to check that your for loop is correct.
8.
In a simulation, you repeatedly generate random numbers and use them to
simulate an activity.
9.
A debugger is a program that you can use to execute another program and
analyze its run-time behavior.
10. You can make effective use of a debugger by mastering just three concepts:
breakpoints, single-stepping, and inspecting variables.
11. When a debugger executes a program, the execution is suspended whenever a
breakpoint is reached.
275
276
12. The single-step command executes the program one line at a time.
13. A debugger can be used only to analyze the presence of bugs, not to show that a
program is bug-free.
14. Use the divide-and-conquer technique to locate the point of failure of a
program.
Search WWH ::




Custom Search