6. แยกย่อย

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.

 
รหัสที่ 6-14  การโยนสิ่งผิดปกติให้กับผู้เรียกเมท็อด
  // เมท็อดแปลงจำนวนเต็มเป็นข้อความ จำกัดให้จำนวนที่แปลงมีค่าได้ตั้งแต่ 0 ถึง 9,999,999
  public static String int2text(int i) {  
    if (i < 0 || i > 9999999) {
      throw new IllegalArgumentException("ค่า " + i + " อยู่นอกช่วง");
    }
    String t = "";
    ... // กลุ่มคำสั่งเดิมที่แปลง i เป็นข้อความเก็บใน t
  }
©2009 S.Prasitjutrakul