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:

NullPointerExceptionArrayIndexOutOfBoundException, ArrayIndexOutOfBoundsException, ClassCastException

https://stackoverflow.com/questions/2190161/difference-between-java-lang-runtimeexception-and-java-lang-exception

Difference between java.lang.RuntimeException and java.lang.Exception的更多相关文章

  1. java异常——RuntimeException和User Define Exception

    1.RuntimeException public class RuntimeException { public static void main(String[] args) { // TODO ...

  2. 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 ...

  3. 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 ...

  4. 转载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 ...

  5. 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': ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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. ...

随机推荐

  1. NSURLProtocol

    An NSURLProtocol object handles the loading of protocol-specific URL data. @abstract This method reg ...

  2. 微信小程序 深拷贝的那些坑。

    网上说的几种方法都不好使,包括直接使用如下: JSON.pars(JSON.stringify(this.data.answer)) ... Object.assign Object.definePr ...

  3. LeetCode 886. Possible Bipartition

    原题链接在这里:https://leetcode.com/problems/possible-bipartition/ 题目: Given a set of N people (numbered 1, ...

  4. 13--网页,网站,微信公众号基础入门(PHP获取网页的get请求)

    https://www.cnblogs.com/yangfengwu/p/11148976.html 大家在访问网页的时候有没有注意一件事情 现在咱来看这种哈 现在咱做个功能哈,类似于这样 长话短说 ...

  5. CCF 201803-3 URL映射

    CCF 201803-3  URL映射 试题编号: 201803-3 试题名称: URL映射 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 URL 映射是诸如 Django. ...

  6. [Shell]多姿势反弹shell

    客户端监听本地: nc -nvlp 4444 从原生的 shell 环境切换到 linux 的交互式 bash 环境: python -c 'import pty; pty.spawn("/ ...

  7. HustOJ二次开发之修改相关Logo

    比如将如图中的HUSTOJ进行修改: 在Linux上修改,通过关键字搜索,会获取如下两个重要文件,找到都有的文字进行修改即可: grep -rn "HUSTOJ" * cd /ho ...

  8. Python3爬取美女妹子图片转载

    # -*- coding: utf-8 -*- """ Created on Sun Dec 30 15:38:25 2018 @author: 球球 "&qu ...

  9. ubuntu16.04 overlay 不支持redirect_dir开关

    modinfo overlay--查看overlay版本 通过linux网站--https://elixir.bootlin.com/linux/v4.4.196/source/fs/overlayf ...

  10. Cookie的Secure属性和HttpOnly属性

    基于安全的考虑,需要给cookie加上Secure和HttpOnly属性,HttpOnly比较好理解,设置HttpOnly=true的cookie不能被js获取到,无法用document.cookie ...