Chapter 4: Making (Best web hosting site) the Most of Variables and
Friday, November 30th, 2007Chapter 4: Making the Most of Variables and Their Values 87 Figure 4-6: The Brickenchicker dectuplets strike again. In Listing 4-5, the allTenOkayvariable is of type boolean. To find a value for the allTenOkayvariable, the program checks to see whether numberOfPeopleis greater than or equal to ten. (The symbols >=stand for greater than or equal to.) At this point, becoming fussy about terminology pays. Any part of a Java program that has a value is called an expression. If you write weightOfAPerson = 150; then 150is an expression (an expression whose value is the quantity 150). If you write numberOfEggs = 2 + 2; then 2 + 2is an expression (because 2 + 2 has the value 4). If you write int numberOfPeople = elevatorWeightLimit / weightOfAPerson; then elevatorWeightLimit / weightOfAPersonis an expression. (The value of the expression elevatorWeightLimit / weightOfAPerson depends on whatever values the variables elevatorWeightLimitand weightOfAPersonhave when the code containing the expression is executed.) Any part of a Java program that has a value is called an expression. In Listing 4-5, the code numberOfPeople >= 10is an expression. The expression s value depends on the value stored in the numberOfPeoplevariable. But, as you know from seeing the strawberry shortcake at the Brickenchicker family s catered lunch, the value of numberOfPeopleisn t greater than or equal to ten. This makes the value of numberOfPeople >= 10to be false. So, in the statement in Listing 4-5, in which allTenOkayis assigned a value, the allTenOkayvariable is assigned a falsevalue.
Please take a look on frontpage web hosting, and see why we provide the most affordable frontpage web hosting on the best equipment.