Java Reference
In-Depth Information
CHAPTER
3
Control Structures
In this chapter, I will discuss the control structures of the Java language, cov-
ering decision making and repetition. Topics in this chapter include a discus-
sion on Boolean logic, truth tables, the if/else statement, the switch statement,
the for loop, and while and do/while loops. If you are new to programming,
spend some time in this chapter. Control structures are fundamental to any
programming language, not just Java. If you are already familiar with struc-
tures like if statements and while loops, pay close attention to the details of
how these are implemented in Java.
Flow of Control
In the programs I have shown you so far and in the programs you have writ-
ten in the labs, there has been a public class with a main() method declared in
it. These programs have begun executing at the first statement in main(), then
each subsequent statement has executed in order until the end of main() is
reached, at which point the programs terminated.
51
Search WWH ::




Custom Search