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. ...
随机推荐
- wordpress调用置顶文章sticky_posts的三种方法
有时我们在开发wordpress时需要调用置顶文章sticky_posts,怎么调用呢?几种写法,有用到query_post的,有用到WP_Query,也有用到is_sticky(),下面随ytkah ...
- self & _cmd
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles ...
- 2018南京区域赛K题 Kangaroo Puzzle——随机&&乱搞
题意 在 n * m 的平面上有若干个袋鼠和墙(1为袋鼠,0为墙),每次可以把所有袋鼠整体往一个方向移动一步(不能走出边界和不能走到墙),为在不超过50000步的情况下能否把全部袋鼠聚集在同一个位置. ...
- python - django 项目部署 Ubuntu 服务器后接口访问一直 502 问题
问题描述:最近有了一台 Ubuntu 的服务器,然后准备部署个项目,结果没想到部署的过程跟用 Centos 的时候还有点不一样,最后一步我是卡在了 uwsgi 这里,访问一直502,且可以访问项目的静 ...
- LeetCode 301. Remove Invalid Parentheses
原题链接在这里:https://leetcode.com/problems/remove-invalid-parentheses/ 题目: Remove the minimum number of i ...
- RFM - Customer Level Data
Introduction ## Warning: package 'DT' was built under R version 3.5.2 RFM (recency, frequency, monet ...
- luogu P3975 [TJOI2015]弦论 SAM
luogu P3975 [TJOI2015]弦论 链接 bzoj 思路 建出sam. 子串算多个的,统计preant tree的子树大小,否则就是大小为1 然后再统计sam的节点能走到多少串. 然后就 ...
- 洛谷2320 bzoj1192 鬼谷子的钱袋
题目链接 题意概述:把正整数n分为m个正整数,m个正整数中不允许出现复数个非1的正整数,保证所有小于n的正整数都可以用一部分正整数的和表示,并且使m尽量小. 这道题不知道为啥bzoj上没有要求输出方案 ...
- 【luoguP2989】[USACO10MAR]对速度的需要Need For Speed
题目描述 最大化平均值 二分一个\(x\) \(check\): \(\frac{F+\sum_{i=1}^{n} X_{i} \times F_{i}}{M+\sum_{i=1}^{n} X_{i} ...
- OpenFOAM——前台阶
本算例来自<ANSYS Fluid Dynamics Verification Manual>中的VMFL037:Turbulent Flow Over a Forward Facing ...