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-8  ตัวอย่างการจัดการสิ่งผิดปกติที่เกิดจากเมท็อด max ในรหัสที่ 10-4
  public static void main(String[] args) {
    Scanner kb = new Scanner(System.in);
    System.out.print("ชื่อแฟ้มข้อมูล = ");
    String fileName = kb.nextLine();
    try {
      double max = max(fileName);  
      System.out.println("max = " + max);
    } catch (FileNotFoundException e) {
      System.out.println("ไม่พบแฟ้ม " + e.getMessage());
    } catch (NoSuchElementException e) {
      System.out.println("แฟ้มนี้ไม่มีข้อมูลเลย " + e.getMessage());
    }    
  }
©2009 S.Prasitjutrakul