If statements are a cornerstone of programming, even outside of Java such as C++ or other languages. An If statement proposes a possibility, a noticed change in the running program, whether it’s how to treat different inputs with output, different ways to handle changing data, etc. There are several different kinds of if statements that are used:
- Basic If Statement: if (value == num) System.out.println(“Value matches number!”);
- Else-If Statement: if (value == num) System.out.println(“You guessed my number!”); else System.out.println(“Wrong number!”);
- Compound If Statement: if (value >= num) { System.out.println(“Value matches number…”); System.out.println(“…or value is greater than number!”); }
- Nested If Statement: if (value != num) { if (value > num) System.out.println(“Value is definitely greater than number!”); }
All of these use syntax of: boolean expression, then test and control flow. A control flow is a visualization of all if statement possibilities. Observe:

With if statements, many possibilities can be explored. You can create a mere data check or mimic a switch statement with a series of complex else-if statement. The power is at your fingertips!