Lesson 8 of 34
&&, || and !: Combining Conditions
8 min 25 XP
&& (AND) is true only when both sides are true. || (OR) is true when either side is true. ! (NOT) flips true to false and false to true.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.A small if/else can be written on one line with the ternary operator: condition ? value1 : value2
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.