在第一个 catch 块中为什么我们不能抛出一个Exception
对象?这里RuntimeException
工作正常。
public class CirEx {
public Circle getCircle(int id) {
Connection conn = null;
try {
Class.forName("");
conn = DriverManager.getConnection("");
PreparedStatement pstmt = conn.prepareStatement("");
Circle circle = new Circle(1, "");
return circle;
} catch (Exception e) {
throw new RuntimeException(e);
// why we cann't do that.
// throw new Exception(e);
} finally {
try {
conn.close();
} catch (SQLException e) {
System.out.println(e);
}
}
}
}