JAVA循环

时间:2020-03-09 18:05:22   收藏:0   阅读:48
 1 public class  Xunhuan {
 2 
 3     public static void main(String[] args) {
 4         // TODO Auto-generated method stub
 5         
 6         //for循环输出0——10
 7         for(int i=0;i<=10;i++) {
 8             System.out.println(i);      //输出
 9         }    
10         
11         //while循环输出0——10
12         int x=0;
13         while(x<10) {
14             System.out.println(x);
15             x++;
16         }
17         //do...whlie循环输出0——10
18         int n=0;
19         do {
20             System.out.println(n);
21             n++;           //自加1
22         }while(n<10);        
23     }
24 }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!