10. สิ่งผิดปกติ

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.

 
รหัสที่ 10-18  การใช้ assert เพื่อตรวจสอบผลหลังการทำงาน
  public static void sort(int[] d) {
    ... // รหัสที่ทำการเรียงลำดับ 

    for (int i=0; i<d.length-1; i++) {
      assert d[i] <= d[i+1];  // ตัวซ้ายต้องไม่มากกว่าตัวขวา 
    }
  }
©2009 S.Prasitjutrakul