throw和throws子句的区别

来源:互联网 发布:数据库管理系统教程 编辑:程序博客网 时间:2024/06/18 05:09

import java.io.IOException


public class ThrowDemo{

public static void processFile(String toFile) throws IOException

{

//Omitted implementation propagates all

//throw  IOException back to the caller

}

public static void main(String[] args){

for(String fileName:args){

try{

processFile(fileName);

}

catch(IOException e){

System.out.println(e);

}

}

}

小结:

throw子句用于抛出异常‘

throws子句用于传播异常



0 0