异常:catch下的return;
生活随笔
收集整理的這篇文章主要介紹了
异常:catch下的return;
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
import java.io.FileNotFoundException;public class TryCatchDemo {public static void main(String[] args) {try {read("b.txt");} catch (FileNotFoundException e) {System.out.println(e);}System.out.println("文件存在");}public static void read(String path) throws FileNotFoundException {if (!path.equals("a.txt")) {throw new FileNotFoundException("文件不存在");}}
}
catch下不加return; 抓到異常后還是會執(zhí)行System.out.println(“文件存在”);
加了之后不會執(zhí)行System.out.println(“文件存在”);
也可以把
總結(jié)
以上是生活随笔為你收集整理的异常:catch下的return;的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: idea debug的使用
- 下一篇: 递归 累加和累乘