07JAVA编程基础7.pptVIP

  • 3
  • 0
  • 约 52页
  • 2016-11-29 发布于重庆
  • 举报
07JAVA编程基础7

异常流程由try ... catch ... finally语句来控制。 如果程序中还包含return和System.exit()句,就会使流程变得更加复杂— 2) return语句用于退出本方法.在执行try或catch代码块中的return语句时,假如有finally代码块,会先执行finally代码块。 ???? public class WithReturn{ public int methodA(int money)throws SpecialException{ if(--money=0) throw new SpecialException(Out of money); return money; } public int methodB(int money){ try{ System.out.println(Begin); int result=methodA(money); //可能抛出异常 return result; }catch(SpecialException e){ System.out.println(e.getMessage()); return -100; }finally{ System.out.println(

文档评论(0)

1亿VIP精品文档

相关文档