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