标签:int() png extends try hex java div 分享图片 idt
这个课程的参考视频和图片来自youtube。
主要学到的知识点有:
We want to handle the bad Error. (e.g bad input / bugs in program)
e.g File I/O; User Input, out of control.
An example that handle the wrong input and out of range input.
1. First we creat two java class (IntegerOutOfRangeException and InputMisMatchException)
public class IntegerOutOfRangeException extends Exception { }
public class InputMisMatchException extends Exception { }
2. Then we will use try and catch to catch the exceptions.
try { i = input.nextint(); if (i < 1 || i > 10) { throw new integerOutOfRangeException(); } catch (inputMisMatchException ex){ System.out.println("you did not enter an integer."); } catch (integerOutOfRangeException ex){ System.out.println("your input value is out of range."); } }
[Java in NetBeans] Lesson 16. Exceptions.
标签:int() png extends try hex java div 分享图片 idt
原文地址:https://www.cnblogs.com/Johnsonxiong/p/10204118.html