package review20140419;
/*
* do while 和 while 的区别
*/
public class Test3 {
//程序的入口
public static void main(String[] args) {
/*定义变量a1,a2,b1,b2*/
int a1=1;
int a2=1;
int b1=20;
int b2=20;
/*相同点*/
//do while 循环
do {
System.out.print(a1);
a1++;
} while (a1<10);
System.out.println();
//while 循环
while(a2<10){
System.out.print(a2);
a2++;
}
System.out.println();
/*不同点*/
//do while 循环
do {
System.out.println(b1);
b1++;
} while (b1<10);
System.out.println("/");
//while 循环
while(b2<10){
System.out.println(b2);
b2++;
}
}
}
输出结果
123456789
123456789
20
/