美文网首页
java异常

java异常

作者: 强化班_刘敬辉 | 来源:发表于2020-05-03 09:28 被阅读0次

java. lang. Throwable

Error:错误

栈溢出:stackoverflowerror

堆溢出:outofmemoryerror

Exception:异常

运行时(java. exe)异常

输入类型异常:inputmismatchexception

    数组下标越界:arrayindexoutofboundsexception

    数学运算异常:arithmeticexception

    类型转化异常:ClassCastException

    空指针异常:nullpointerexception

编译时(java. exe)异常

    io空文件:filenotfoundexception

异常之后代码不在执行

捕获异常

1. try…catch…finally语句(try内变量为局部变量、知道异常类型)

printstacktrace打印堆栈信息

getmessage得到异常类型

2. 声明抛出异常throws exception(不知道异常类型、向上抛出,直至改变为运行时异常)

相关文章

网友评论

      本文标题:java异常

      本文链接:https://www.haomeiwen.com/subject/agarghtx.html