Grokking Java Basics
0% completed
Java if...else Statement
Conditional statements in Java are used to perform different actions based on different conditions. The simplest forms are the if statement and the if...else statement. These statements allow your program to execute code selectively depending on whether a condition is true or false.
The if Statement
The if statement evaluates a boolean expression (a condition) and executes a block of code only if the condition is true. If the condition evaluates to false, the code block is skipped.
Syntax
if (condition) { // Code to execute if condition is true }
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%