Control Flow

Conditionals and loops: if-else, switch, for, while, do-while.


Control flow statements decide the order in which statements execute: if/else if/else, switch, for, while, do-while, break and continue.

Example
for(int i = 0; i < 5; i++) {
  if(i % 2 == 0) System.out.print(i);
}
Video Lesson Open in new tab
Quiz
1. How many times does this loop run? for(int i=0;i<5;i++)
Coding Problems
1. Write a Java program to print the sum of numbers from 1 to 100 using a for loop.
Discussion

Login to join the discussion.


No comments yet.