返回列表 發帖

while 迴圈 (一)

利用 while 迴圈, 直列印出1~10.

  1. public class Hello
  2. {
  3.         public static void main(String[] args)
  4.         {   
  5.                 int i=1;
  6.                 while(i<=10)
  7.                 {
  8.                         System.out.println(i);
  9.                         i++;
  10.                 }
  11.         }
  12. }
複製代碼

TOP

  1. public class eric{
  2.     public static void main(String args[])
  3.     {
  4.          {
  5.              int a=0;
  6.         while(a<=10)
  7.         {
  8.              System.out.println(a);
  9.              a++;
  10.          }
  11.     }
  12. }
複製代碼

TOP

  1. package bbs.istak.org.tw;

  2. public class Main {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 int i =1;
  6.         while(i<=10)
  7.         {
  8.                 System.out.println(i);
  9.                 i++;
  10.         }
  11.         }

  12. }
複製代碼
寶寶心裡苦,但寶寶不說。

TOP

  1. package bbs.istak;

  2. public class BB {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5. int i=0;
  6. while(i<=9) {
  7.         i++;
  8.         System.out.println(i);
  9.         }

  10. }
  11.        
  12. }
複製代碼

TOP

  1. package bn.tw;

  2. public class Main {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 int count =1;
  6.                 while(count<=10)
  7.                 {
  8.                         System.out.println(count);
  9.                         count++;
  10.                 }
  11.                 }
  12.         }
複製代碼

TOP

  1. package morris;

  2. public class Main {

  3.         public static void main(String[] args) {
  4.                 int a=1;
  5.         while(a<=10)
  6.         {
  7.                 System.out.println(a);
  8.                 a++;
  9.         }
  10.    }

  11. }
複製代碼

TOP

返回列表