Java学习----finally块
2016-01-17 16:20
459 查看
public class Test { String x; public static void main(String[] args) { Test test = new Test(); try { System.out.println(5/0); } catch (ArrayIndexOutOfBoundsException e) { test.x = "hello world"; System.out.println(test.x.length()); } catch (NullPointerException e) { // TODO: handle exception test.x = "hello world"; System.out.println(test.x.length()); } catch (Exception e) { // 必须放到最后 // TODO: handle exception e.printStackTrace(); }finally { System.out.println("finally"); } System.out.println("end"); } }
java.lang.ArithmeticException: / by zero at com.demo.pkg5.Test.main(Test.java:10) finally end
相关文章推荐
- Java学习----有风险的代码(异常)
- Spring mvc 初始化过程
- spring-如何给静态变量注入值
- Java反射机制
- Java 入门 之 Eclipse及其快捷键
- Spring2.5学习3.3_@Autowire注解实现手动装配
- SSH进阶(1)——javax.mail 实现邮件发送
- 【JAVA】Java文件的读写
- Struts2配置
- Struts框架搭建时所遇到的问题
- Java 入门 之 数组与循环
- org.eclipse.core.runtime.CoreException: The Class File Viewer cannot handle the given input ('org.ec
- java调用存储过程
- 中文和unicode互转
- JAVA OO 第二章知识点
- 浅析Java中CountDownLatch用法
- JavaWeb_SpringMVC和titles的简单整合
- Eclipse下Preferences解析
- 【转】零基础写Java知乎爬虫之进阶篇
- java BigInteger 的使用