How does the for loop exactly work out [closed]

A for loop works as follows:

  1. Initialization is done (int i=0 in your case; only executed once)
  2. Condition is checked (i<=100 here), if condition is false leave the loop
  3. Code within the braces is executed (System.out.println(i); in your case)
  4. Update statement is executed (i++)
  5. Goto 2.

Leave a Comment