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-4  เมท็อด max หาจำนวนที่มีค่ามากสุดในแฟ้ม
  public static double max(String fn)  
             throws FileNotFoundException, NoSuchElementException {
    Scanner in = new Scanner(new File(fn));

    if (!in.hasNext()) throw new NoSuchElementException(fn);
    double max = readDouble(in, "");
    while (in.hasNext()) {
      double v = readDouble(in, "");
      if (max < v) max = v;
    }
    return max;
  }   
©2009 S.Prasitjutrakul