WHAT YOU WILL LEARN IN THIS CHAPTER:
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
wrox.com code downloads for this chapter are found at
www.wrox.com/go/beginningjavaprogramming on the Download Code tab. The code is in the Chapter 5 download and individually named according to the names throughout the chapter.
Control structures allow a programmer to define how and when certain statements will be executed. In other words, if certain conditions are met, specified behaviors will result. Several structures exist in Java and other languages, such as loops and if-then statements, which allow this control to be implemented. This chapter begins by introducing (or re-introducing) some operators that will be used extensively in control structures. The operators, essentially, allow you to compare values. In order to make similar comparisons on different data types, some comparative methods will also be introduced. Once you can make these comparisons and assessments, you can start using them to make decisions. That is where the if-then statement comes in. In its simplest form, this structure can be read as follows: if some condition is true, then do something. Next, you will look at
while loops, and some extensions of these, ...