Java Reference
In-Depth Information
6
More Conditionals
and Loops
CHAPTER OBJECTIVES
●
Examine conditional processing using switch statements.
●
Discuss the conditional operator.
●
Examine alternative repetition statements: the do and for loops.
●
Draw graphics with the aid of conditionals and loops.
●
Explore the use of dialog boxes.
I
n Chapter 5 we examined the
if
statement for making decisions
and the
while
statement for looping. This chapter explores several
additional statements in Java for performing similar tasks. In particu-
lar, in this chapter we'll explore the
switch
statement, which allows
us to choose among several paths of execution based on a specific
value. We'll also explore the
do
and
for
loops, which provide logical
processing and/or syntax that distinguish them from the
while
loop.
These alternative statements differ in key details, and any particular
situation may lend itself to the use of one over another. The Graphics
Track sections of this chapter explore the use of conditionals and
loops to control our graphics and examine the purpose and use of
dialog boxes.
269
Search WWH ::
Custom Search