Tutorials Courses Interview Prep (100 Q&A) AI Tools (50) Developer Tools (50) Tracks Pricing Plans Blog & Articles Contact Us
Core Java & Object-Oriented Architecture 16 mins read Free Lesson

Java Control Flow: Conditional & Loops

Control application execution with if-else, modern switch expressions, for, while, and enhanced for-each loops.

Conditional Statements & Loops

// Enhanced Switch Expression (Java 14+)
String dayType = switch (day) {
    case "SATURDAY", "SUNDAY" -> "Weekend";
    default -> "Weekday";
};

// Enhanced For-Each Loop over Arrays
int[] numbers = {10, 20, 30, 40, 50};
for (int num : numbers) {
    System.out.println("Value: " + num);
}