请问在java里有try但没有catch对不对

来源:百度知道 编辑:UC知道 时间:2024/07/13 17:27:16
例:try { return next(rs);}
finally {stmtt.close();
stmtt = null;}

catch和finally 有一个就行了

要看具体情况,java里的异常分2种,运行时异常和非运行时异常,如果是运行时异常,也就是不 强制catch的异常,可以省略catch,直接try finally
否则,如果不catch该异常或者没有在方法中throws,编译无法通过,也就是说要看具体的异常

不对 ,首先编译的时候就有问题。你可以写catch 但是不做任何处理啊。
try { return next(rs);}
catch(Exception e)
{}
finally {stmtt.close();
stmtt = null;}

不对,因为try-catch必须是配对出现

不对