Introduction

Iterations in essence is counting. You have to repeatedly do a task a certain number of times and the conditions within your loops determines how many times you do it. Whether you’re dealing with a for loop or a while loop you will need the following to count properly:

For Loop

Check this video for visualization of the for loop:

https://www.youtube.com/watch?v=Hj0czMprXhc

Example 1: increment by 1

for (int i=0; i<3; i++){
	System.out.println(i);
}
// rest of the code

Example 2: decrement by 1

for (int i=3; i>0; i--){
	System.out.println(i);
}
// rest of the code