异常处理 学习笔记(二)
2013-11-14 16:58
309 查看
public class TestThrow { public static void main(String[] args) { try { throwChecked(-3); } catch(Exception e) { System.out.println(e.getMessage()); } throwRuntime(3); } public static void throwChecked(int a) throws Exception { if(a>0) { throw new Exception("a的值大于0,不符合要求。"); } } public static void throwRuntime(int a) { if(a>0) { throw new RuntimeException("a的值大于0,不符合要求。"); } } }
相关文章推荐
- java学习笔记7 - Spring mvc 统一异常处理和静态文件的配置
- 【Java学习笔记之三十二】浅谈Java中throw与throws的用法及异常抛出处理机制剖析
- 【OpenCV学习笔记】【异常处理】一(The Matrix is not continuous, thus its number of rows can not be changed)
- 学习笔记之C#类、循环中的语句、基础知识和异常处理
- 中断+异常处理【学习笔记】
- Effective C# 学习笔记(四十七)对异常进行strong guarantee 策略处理
- JavaSE学习笔记之-----异常处理
- WCF 学习笔记之异常处理
- 【Java学习笔记之三十二】浅谈Java中throw与throws的用法及异常抛出处理机制剖析
- Struts 1 学习笔记-5-3(Struts的自动处理异常以及模式套用)
- 7. 异常处理 --- 学习笔记
- [Python学习笔记][第八章Python异常处理结构与程序调试]
- <<Linux内核完全剖析 --基于0.12内核>>学习笔记 第4章 80x86保护模式及其编程 4.6 中断和异常处理
- Python学习笔记--异常处理
- va异常处理学习笔记
- 关于SQLServer2005的学习笔记—异常捕获及处理
- 20170729学习笔记之异常处理
- JAVA学习笔记_关于异常机制处理问题
- python学习笔记(九)异常处理
- Python中的异常处理学习笔记