Conditional Statements
In Chapter 3, we learned about Java operators. We discussed two important properties of operators, namely, precedence and associativity. Precedence helps group shared operands. When precedence levels match, associativity is then used for grouping.
We discussed the unary operators – prefix and postfix increment/decrement, cast, and logical NOT. We also covered the binary operators – arithmetic, relational, logical, bitwise, and compound assignment. We learned about the behavior of the +
symbol when one (or both) operands is a string. We discussed the logical AND (&&
) and logical OR (||
) and their short-circuiting property. Finally, the ternary operator, with its three operands, was covered.
We also learned about Java casting. This can be done implicitly, known as implicit promotion or widening. The other alternative is explicit casting, known as narrowing. When narrowing, we must cast to the target type in order to remove the compiler...