Professional Documents
Culture Documents
Java
Three basic loops:
• for
• while
• do-while
Syntax of for loop:
while(condition)
{
statement(s);
}
Simple while loop example
class WhileLoopExample {
public static void main(String args[]){
int i=10;
while(i>1)
{
System.out.println(i);
i--;
}
}}
The output of this program is:
10
9
8
7
6
5
4
3
2
Syntax of do-while loop:
do
{
statement(s);
}
while(condition);
do-while loop example
class DoWhileLoopExample {
public static void main(String args[]){
int i=10;
do {
System.out.println(i); i--;
}
while(i>1);
}
}
Output:
10
9
8
7
6
5
4
3
2
Title and Content Layout with Chart
Two Content Layout with Table
• First bullet point here
Group 1 Group 2
• Second bullet point here
Class 1 82 95
• Third bullet point here
Class 2 76 88
Class 3 84 90
Two Content Layout with SmartArt
• First bullet point here
Group
A
Task Task
3 2