8. วัตถุสิ่งของ

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.

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