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. Angular pagination分页模块 只提供分页参数处理 不处理分页记录数据

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  2. npm install 命令。默认会找到当前路径下的package.json。然后安装其中的依赖

    npm install 命令.默认会找到当前路径下的package.json.然后安装其中的依赖 By default, npm install will install all modules li ...

  3. hdu1540-Tunnel Warfare-(线段树+二分)

    题意:有n个村庄排成一列,相邻的村庄可以通信,炸毁则不可以通信,进行m个操作.3种操作,1.炸毁某村庄:2.修复上一个被炸毁的村庄:3.查询某个村庄能通信的村庄数(自己算一个). 解题:求某个点左边扩 ...

  4. 【转载】java.util.ServiceConfigurationError: com.sun.tools.attach.spi.AttachProvider

    https://blog.csdn.net/zqz_zqz/article/details/80922164 window上运行以下代码获取jvm进程: List<VirtualMachineD ...

  5. 验证码破解 | Selenium模拟登陆12306

    12306官网登录的验证码破解比较简单,验证码是常规的点触类型验证码,使用超级鹰识别率比较高. 思路: (1)webdriver打开浏览器: (2)先对整个屏幕截屏,通过标签定位找到验证码图片,并定位 ...

  6. timeout/timelimit

    timelimit

  7. codeblock代码片段

    for循环 ; $(index name)<| ; $(index name)++ ){ } 2. 反向for循环 ; $(index name)>= ; $(index name)-- ...

  8. Flume 实战,将多台机器日志直接收集到 Kafka

    目前我们使用的一个 b 端软件的报错日志分散在集群各处,现在想把它收集到一个地方然后统一丢进 Kafka 提供给下游业务进行消费. 我想到了 flume,之前让同事搭建的这次自己想多了解一些细节于是就 ...

  9. SpringBoot:缓存注解@Cacheable详解

    1.查看@Cacheable @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) @ ...

  10. Asp.net 与 Core .net 用法区别

    1.  定义一个类 如下,注意int?这里 public class A{ public int? num{get;set;} } 2. 如果传递的参数不能转换成int类型,则core里面接受不了参数 ...