java tutorial - The If-Else If Statement, Nested If Statements, Logical Operators in Java - java programming - learn java - java basics - java for beginners
Learn java - java tutorial - The If-Else If Statement, Nested If Statements, Logical Operators - java examples - java programs
If-Else If Statement:
- Sometimes you need to be able to test a series of conditions
- You can do this with the if-else if statement
- If BooleanExpression1 is true, then the statement or block 1 is executed.
- If BooleanExpression1 is false, then the BooleanExpression2 is tested.
- If BooleanExpression2 is true, then the statement or block 2 is executed.
- If BooleanExpression2 is false, then the statement or block 3 is executed.
Nested if Statements:
- Nesting is enclosing one structure inside of another.
- A block in Java can contain any valid Java code, this includes other if statements:
- Java provides logical operators.
- Binary logical operators combines two different boolean expressions into one.
- The unary logical operator switches the value of a boolean expression.
- Binary logical operators have lower precedence than relational operators (they will be evaluated after)
- NOT has the same precedence as negation.