You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Control flow statements determine the order in which instructions are executed. Java provides conditionals (if, switch) and loops (for, while, do-while) to make programs dynamic and responsive.
int score = 85;
if (score >= 90) {
System.out.println("Grade: A");
} else if (score >= 80) {
System.out.println("Grade: B");
} else if (score >= 70) {
System.out.println("Grade: C");
} else {
System.out.println("Grade: F");
}
| Operator | Meaning |
|---|---|
== | Equal to |
!= | Not equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
| Operator | Meaning | Example |
|---|---|---|
&& | AND | a > 0 && b > 0 |
|| | OR | a > 0 || b > 0 |
! | NOT | !finished |
A concise alternative to simple if/else:
String result = (score >= 60) ? "Pass" : "Fail";
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.