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-8  เมท็อดคืนค่ามากสุดในอาเรย์
  public static double max(double[] d) {  
    if (d.length == 0) throw new IllegalArgumentException("0 ช่อง");
    double max = d[0];
    for (int i=1; i<d.length; i++) {
      if (d[i] > max) max = d[i];
    }
    return max;
  }
©2009 S.Prasitjutrakul