Java Reference
In-Depth Information
3.1
Branching Mechanism
94
Statements
94
If-else
3
Omitting the
95
else
Compound Statements
96
Nested Statements
98
Multiway
Statement
98
if-else
Example: State Income Tax
99
The
Statement
101
switch
★
The Conditional Operator
106
3.2
Boolean Expressions
107
Flow of Control
Simple Boolean Expressions
107
Lexicographic and Alphabetical Order
110
Building Boolean Expressions
113
Evaluating Boolean Expressions
114
Short-Circuit and Complete Evaluation
118
Precedence and Associativity Rules
119
3.3
Loops
126
Statement and
Statement
126
while
do-while
Algorithms and Pseudocode
128
Example: Averaging a List of Scores
131
The
Statement
132
for
The Comma in
Statements
135
for
Nested Loops
139
★
The
and
Statements
142
break
continue
The
Statement
143
exit
3.4
Debugging
144
Loop Bugs
144
Tracing Variables
144
General Debugging Techniques
145
Example: Debugging an Input Validation Loop
149
Preventive Coding
150
★
Assertion Checks
151
Chapter Summary
153
Answers to Self-Test Exercises
154
Programming Projects
159