Difference between java.lang.RuntimeException and java.lang.Exception
In Java, there are two types of exceptions: checked exceptions and un-checked exceptions. A checked exception must be handled explicitly by the code, whereas, an un-checked exception does not need to be explicitly handled.
For checked exceptions, you either have to put a try/catch block around the code that could potentially throw the exception, or add a "throws" clause to the method, to indicate that the method might throw this type of exception (which must be handled in the calling class or above).
Any exception that derives from "Exception" is a checked exception, whereas a class that derives from RuntimeException is un-checked. RuntimeExceptions do not need to be explicitly handled by the calling code. If RuntimeExceptions aren't caught in the code, they will be handled by JVM.
e.g common RuntimeExceptions:
NullPointerException, ArrayIndexOutOfBoundException, ArrayIndexOutOfBoundsException, ClassCastException
Difference between java.lang.RuntimeException and java.lang.Exception的更多相关文章
- java异常——RuntimeException和User Define Exception
1.RuntimeException public class RuntimeException { public static void main(String[] args) { // TODO ...
- Caused by: java.lang.RuntimeException: by java.lang.OutOfMemoryError: PermGen space(tomcat 启动时提示内存溢出)
设置MaxPermSize大小TOMCAT_HOME/bin/catalina.bat 文件头加set JAVA_OPTS='-Xms512m -Xmx1024m -XX:MaxPermSize=51 ...
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.love5/com.example.love5.Main11Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.
若有 java.lang.RuntimeException和 java.lang.NullPointerException: Attempt to invoke virtual method 'voi ...
- 转载java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.spinner/com.example.spinner.MainActivity}: java.lang.NullPointerException
今天学习Android开发突然遇到了这个问题,查阅了很多资料,并且对集中原因进行了分析. 错误信息字符串:java.lang.RuntimeException: Unable to start act ...
- nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoSupport': ...
- hive脚本出现Error: java.lang.RuntimeException: Error in configuring object和Caused by: java.lang.IndexOutOfBoundsException: Index: 9, Size: 9
是在reduce阶段报的错误,详细错误信息是 朱传豪 19:04:48 Diagnostic Messages for this Task: Error: java.lang.RuntimeExcep ...
- QA:java.lang.RuntimeException:java.io.FileNotFoundException:Resource nexus-maven-repository-index.properties does not exist.
QA:java.lang.RuntimeException:java.io.FileNotFoundException:Resource nexus-maven-repository-index.pr ...
- java.lang.RuntimeException: Invalid action class configuration that references an unknown class named [xxxAction]。
java.lang.RuntimeException: Invalid action class configuration that references an unknown class name ...
- eclipse 4 rcp: java.lang.RuntimeException: No application id has been found.
错误详情: java.lang.RuntimeException: No application id has been found. at org.eclipse.equinox.internal. ...
随机推荐
- Opencv 初探 常用API
一.介绍 OpenCV是计算机视觉领域应用最广泛的开源工具包,基于C/C++,支持Linux/Windows/MacOS/Android/iOS,并提供了Python,Matlab和Java等语言的接 ...
- React Tutorial: Basic Concept Of React Component---babel, a translator
Getting started with react.js: basic concept of React component 1 What is React.js React, or React.j ...
- windows10家庭版升级专业版/企业版
以防万一,还是把Windows10家庭版的密钥保存下来. 一.保留原密钥 1. Win+R,输入regedit 2. 进入目录 HKEY_LOCAL_MACHINE\SOFTWARE\Microsof ...
- react知识点总结(持续更新。。。)
一.webpack 1. 什么是以及为什么要使用webpack 现在的网页功能越来越丰富,所需要的JavaScript和模块也会很多,为开发更加简洁,出现了以下方法,如模块化,scss,typescr ...
- python Image open读取网络图片本地显示 爬虫必备
#!/usr/bin/python3 # -*- coding: utf-8 -*- import requests from PIL import Image from io import Byte ...
- E. Antenna Coverage (dp)
传送门 题意: 在一个一维坐标上,有 n 个东西, 每个东西, 用 xi, si 表示 这个东西在 xi 位置上, 它能覆盖到的区间为 [ xi - si, xi + si ]: 然后, 你可以对任意 ...
- thymeleaf做if判定
<div class="showing"> <h2>条件判断</h2> <p th:if="${testBoolean}&quo ...
- ES6 let 和const
一.var 的缺陷:var 只有全局作用域和函数作用域,没有块级作用域,除了在函数内部的变量默认都属于window var foo='hello'; fn=function(){ var foo='w ...
- 【JZOJ6230】【20190625】梦批糼
题目 一个$n\times m \times l $的立方体,有一些位置有障碍 一次操作会随机选择一个立方体,共有\(w\)次操作 询问所有操作都不选到障碍点,被选到至少一次的点的期望 $n ,m,l ...
- 【CF1142B】Lynyrd Skynyrd
[CF1142B]Lynyrd Skynyrd 题面 洛谷 题解 假设区间\([l,r]\)内有一个循环位移,那么这个循环位移一定有一个最后的点,而这个点在循环位移中再往前移\(n-1\)个位置也一定 ...