45_while循环

 1 /*
 2     水仙花
 3     需求:
 4         在控制台输出所有的“水仙花数”
 5 */
 6 public class OperatorDemo{
 7     public static void main(String[] args){
 8         //需求:在控制台输出5次“HelloWorld”
 9         //for循环实现
10         for(int i = 1;i <= 5;i++){
11             System.out.println("HelloWorld");
12         }
13         System.out.println("--------");
14         
15         //while 循环实现
16         int j = 1;
17         while(j<5){
18             System.out.println("HelloWorld");
19             j++;
20         }
21     }
22 }

 

posted @ 2020-08-07 14:14  找不到北的北  阅读(133)  评论(1)    收藏  举报