Lesson 3 of 10
Operators & Conditions
Java uses standard operators. Conditions use if/else if/else. The ternary operator ? : provides a shorthand for simple if/else. Use == for primitive comparison and .equals() for String comparison.
JAVA
int score = 85;
if (score >= 90) {
System.out.println("A");
} else if (score >= 80) {
System.out.println("B");
} else {
System.out.println("C");
}
// Ternary
String result = (score >= 60) ? "Pass" : "Fail";