In this code will someVar be set even if the catch block is executed and the second Exception is thrown?
public void someFunction() throws Excep
Finally, block always executes.
public class ExceptionTest {
public static void someFunction(String input) throws Exception {
try {
if( input.equals("ABC") ) {
System.out.println("Matched");
}
} catch (Exception e) {
throw new Exception(e);
} finally {
System.out.println("Input Is "+input+" Finally Executed!!!");
}
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
System.out.println("********* Test with VALUE ********* ");
someFunction("ABC");
System.out.println("\r\n********* Test with NULL ********* ");
someFunction(null);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}