作者Mylesksf (斯文狂野小幼狼≧﹏≦)
看板java
标题Re: [问题] Exception的问题
时间Mon Apr 17 12:05:18 2006
※ 引述《oabgg (佑子)》之铭言:
: 程式码大致如下
: =====================================================================
: public class Translator extends Loader{
: public static void main(String args[]) throws Exception{
: new Translator().Translator();
: }
: public void Translator() throws Exception{
^^^^^^^^^^^^^^^^
既然下面都已经catch了,为什麽还要throw呢
: try{
: ......
: unit(refPath);
: ......
: moveFile(refPath,array[i]);
: ......
: }catch(IOException e){
: throw new IOException(e.getMessage());
: }catch(SQLException e){
: throw new SQLException(e.getMessage());
: }catch(Exception e){
: throw new Exception(e.getMessage());
: }finally{
: .........
: }
: }
接在method後面的throws Exception是说
在该method里面的code可能产生exception,可是你没有catch,所以才要丢出去
给其他上层的程式(呼叫这个method的) 来处理
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.133.184.17
※ 编辑: Mylesksf 来自: 220.133.184.17 (04/17 12:05)