Java Reference
In-Depth Information
K EY T ERMS
Boolean expression 76
boolean data type 76
Boolean value 76
conditional operator 104
dangling else ambiguity 85
debugging 106
fall-through behavior 101
flowchart 78
lazy operator 96
operator associativity 105
operator precedence 104
selection statement 76
short-circuit operator 96
C HAPTER S UMMARY
1.
A boolean type variable can store a true or false value.
2.
The relational operators ( < , <= , == , != , > , >= ) yield a Boolean value.
3.
Selection statements are used for programming with alternative courses of actions.
There are several types of selection statements: one-way if statements, two-way
if-else statements, nested if statements, multi-way if-else statements, switch
statements, and conditional expressions.
4.
The various if statements all make control decisions based on a Boolean expression .
Based on the true or false evaluation of the expression, these statements take one of
two possible courses.
5.
The Boolean operators && , || , ! , and ^ operate with Boolean values and variables.
6.
When evaluating p1 && p2 , Java first evaluates p1 and then evaluates p2 if p1 is
true ; if p1 is false , it does not evaluate p2 . When evaluating p1 || p2 , Java first
evaluates p1 and then evaluates p2 if p1 is false ; if p1 is true , it does not evaluate
p2 . Therefore, && is referred to as the conditional or short-circuit AND operator , and
|| is referred to as the conditional or short-circuit OR operator .
7.
The switch statement makes control decisions based on a switch expression of type
char , byte , short , int , or String .
8. The keyword break is optional in a switch statement, but it is normally used at the
end of each case in order to skip the remainder of the switch statement. If the break
statement is not present, the next case statement will be executed.
9. The operators in expressions are evaluated in the order determined by the rules of
parentheses, operator precedence , and operator associativity .
10.
Parentheses can be used to force the order of evaluation to occur in any sequence.
11.
Operators with higher precedence are evaluated earlier. For operators of the same
precedence, their associativity determines the order of evaluation.
12.
All binary operators except assignment operators are left-associative; assignment
operators are right-associative.
 
 
Search WWH ::




Custom Search