Jan 30
The while statement is used to repeat a block of statements while some condition is true. The condition must become false somewhere in the loop, otherwise it will never terminate.
int i = 1;
while (i <= 5) {
System.out.println(i + " squared is " + (i * i));
i++;
}
The output result for the above could would be
1 squared is 1
2 squared is 4
3 squared is 9
4 squared is 16
5 squared is 25
