7. แถวลำดับ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 7-5  การสร้างและตั้งค่าเริ่มต้นให้กับอาเรย์ด้วยรายการเริ่มต้น
  public static String getDayOfWeek(int d) {
    if (d < 0 || d > 6) throw new IllegalArgumentException("d="+d);
    String[] dow =  
      new String[] {"เสาร์","อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์"};
    return dow[d];
  }
©2009 S.Prasitjutrakul