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. ...
随机推荐
- Codeforces Round #552 (Div. 3)-C-Gourmet Cat
http://codeforces.com/contest/1154/problem/C 题意: 有一只猫,周一周四周日吃鱼肉,周二周六吃兔肉,周三周五吃鸡肉,现给出三种肉的数量,问最多能吃多少天? ...
- solidworks 学习 (二)
洗手液瓶建模
- Navicat连接oracle,出现Only compatible with oci version 8.1
与本地oracle连接的时候,一般没问题,sqlplus和oci都是本地oracle自带的,(设置: 工具->选项->oci) 分别为: oci:D:\app\pcman\prod ...
- RPM包——查询
1.rpm -q (1) 查询是否已经安装某一个rpm包: 例如:rpm -q httpd (2)-qa:查询所有的已经安装的包: 2.查询软件包的详细信息: rpm -qi -i :查询软件包 ...
- Docker 更改容器映射端口
1.编辑容器的配置文件进行更改端口: docker run 运行启动时 -p 可以指定容器启动映射端口 ( ) 可以编辑配置文件 进行修改:(需要重启docker 服务 不止是是容器 才能生效.只能重 ...
- SIT系统整合测试
System Integrate Test的缩写,即系统整合测试 系统整合测试就是评估产品在其规格范围内的环境下工作,能否完成产品设计规格所需要的功能及与周边设备.应用软件的兼容性.大致可以 ...
- Linux防火墙配置方法
1)查看防火墙状态 查看防火墙状态: /etc/init.d/iptables status 暂时关闭防火墙: /etc/init.d/iptables stop 重启防火墙: /etc/init.d ...
- shell 编写进度条
test.sh #!/bin/bash i= bar='' label=("|" "/" "-" "\\") ] do ...
- win10重装win7 无法引导
品牌机win10回滚win7 无法引导 BIOS设置 按键盘上的右方向键(→)选择到"Exit" 按键盘上的下方向键(↓)选择到 "OS Optimized Defaul ...
- Asp.net 与 Core .net 用法区别
1. 定义一个类 如下,注意int?这里 public class A{ public int? num{get;set;} } 2. 如果传递的参数不能转换成int类型,则core里面接受不了参数 ...