for( statement1; statement2; statement3;){
// code block to execute
}
statement1 : One time executed. We declare the variable here for (int i=0; i<5; i++) {
System.out.println(i);
}
Output is here
0
1
2
3
4
for (int i=0; i<5; i=i+2) {
System.out.println(i);
}
Output is here
0
2
4
Here the i value is increased by 2 for each iteration step.
for (int i=0; i<5; i=i+5) {
System.out.println(i);
}
Output is here
0
The loop will execute once only as the value of i will be 5 after first loop and the condition became false.
for (int i=10; i<5; i++) {
System.out.println(i);
}
No output will be generate as the condition is false in first check. The code block inside the for loop will never be executed.

for (int i=0; i<5; i++) {
if ( i==3 ) {
break;
}
System.out.println(i);
}
Above code will print
0
1
2
Once i value became 3 , the if condition became true and the execution comes out of the loop. So only i value upto 2 is printed. for (int i=0; i<5; i++) {
if ( i==3 ) {
continue;
}
System.out.println(i);
}
Output is here
0
1
2
4
Note that 3 is not included in the output as we have used if condition with continue to skip further execution. However it continues the loop after that step and prints 4.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.