Conditional Statements
if/else, logical && and ||, comparing strings with equals.
The if statement executes a block of code when the condition is true. Comparisons: == != < > <= >=; logical connectives: && (AND), || (OR), ! (NOT).
Equality is two signs ==. A single = is assignment.
Java
Enter a number — the program will say whether it is even
A special Java trap that the other course languages don't have: strings must NOT be compared with ==. The == operator compares object references, not string contents. For strings always use the equals method.
Java
Enter a word, for example: yes
Task: read three numbers and print the largest (an if / else if / else chain plus the && connective).
Then solve the attached problem "Even or Odd" and mark the lesson as completed.