java tutorial - Java Conditional statement - java programming - learn java- java basics - java for beginners
- In the previous lesson, did we consider the conditional statement? : (a question mark and a colon) in Java that can be used to replace the if..else statements. It has the following general form:
- Where Exp1, Exp2 and Exp3 are expressions. Note the use and placement of the colon.
To determine the value of the entire expression, you first need to evaluate Exp1:
- If the value of Exp1 is true and then the value of Exp2 can be the value of entire expression.
- If the value of Exp1 is false, Exp3 is calculated and its value becomes the value of entire expression.