Java process control (2) loop
•
Java
while Loop
int i = 0;
while(i<10)
{
System.out.println(i);
i++;
}
System.out.println("跳出循环!");
//输出0 1 2 3 4 5 6 7 8 9 跳出循环!
do.. while Loop
int a = 0;
do{
a++;
System.out.println(a);
}while(a<0);
System.out.println("跳出循环~");
Do {statement} while (XX). Different from simple while, the do... While structure will execute the code in the loop body at least once, and then make judgment.
For loop
for(int i=1;i<=10;i++)
{
System.out.print(i+" ");
}
About the for loop
be careful:
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码