Categories
java

for loop in java

for loop used to iterate an array or used to repeat a set of code for predefined times

Syntax

for(;;){
    // your logic
}

Example

   for (int i = 0; i < 10; i++) {
             System.out.println("Loop count " + i);
         }

Ouput

Loop count 0
Loop count 1
Loop count 2
Loop count 3
Loop count 4
Loop count 5
Loop count 6
Loop count 7
Loop count 8
Loop count 9