java 异常

 java异常类结构

  • 常见的 OutOfMemoryError, StackOverflowError 不是直接继承Error而是在Error =>VirtualMachineError

    – StackOverflowError:Thrown when a stack overflow occurs because an application recurses too deeply.(递归过深)
    – OutOfMemoryError:Thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector. OutOfMemoryError objects may be constructed by the virtual machine as if suppression were disabled and/or the stack trace was not writable.(空间不足)

  • checked exception和unchecked exception
    继承Exception来实现checked exception (IDE会提示处理异常)
    继承RuntimeException实现unchecked exception (IDE不提示,程序运行过程中有错误才会报错)
    checked exception 和unchecked exception 演示

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值