所以假设我有三个java类A,B和C(不是实际的java语法),请参阅下面的内容,我在class B
中有一些代码,我在class C
发生异常时不执行该代码行有没有办法管理这种情况?
A.java
class A{
method a() {
try{
//calling method b
B bObj= new B();
bObj.b();
}catch{
}
}
public static void main(String arg[]){
a();
}
}
B.java
class B {
method b()throws Exception {
//calling method c
C cObj = new C();
cObj.c();
/// here is some line of code
// which i dont wana execute when exception occurred in method c
}
}
C.java
class C {
metho c(){
try {
//database connection
// executing query
}catch{
// closing connection
}
} // end of method c
}