返回列表 發帖
  1. public class Ch06 {
  2.         public static void main(String args[]) {
  3.                 String a[] = { "春", "夏", "秋", "冬" };
  4.                 System.out.print("陣列a: ");
  5.                 for (int i = 0; i < 4; i++)
  6.                         System.out.print(a[i] + " ");
  7.                 System.out.println();

  8.                 String b[] = new String[] { "甲", "乙", "丙", "丁" };
  9.                 System.out.print("陣列b: ");
  10.                 for (int i = 0; i < 4; i++)
  11.                         System.out.print(b[i] + " ");
  12.                 System.out.println();

  13.                 int c[];
  14.                 c = new int[] { 1, 2, 3, 4 };

  15.                 System.out.print("陣列c: ");
  16.                 for (int i : c)
  17.                         System.out.print(i + " ");
  18.                 System.out.println();

  19.                 String d[] = new String[4];
  20.                 d[0] = "A";
  21.                 d[1] = "B";
  22.                 d[2] = "C";
  23.                 d[3] = "D";

  24.                 System.out.print("陣列d: ");
  25.                 for (String s : d)
  26.                         System.out.print(s + " ");
  27.                 System.out.println();
  28.         }

  29. }
複製代碼

TOP

返回列表