for loop has 3 parts separated by semicolon (
. All fields are optional, but two semi colons are mandatory.
1. initial assignment - executed only one before entering the for loop
2. Condition - evaluated after executing loop each and every time.
3. Increment - incremented after executing loop each and every time.
example: The for loop will be executed 10 times.
for(int i = 0; i < 10; i++)
example: The following example is infinite for loop
for( ; ; )
While loop only one part that is condition.
// do something in infinite for loop