class ThreeException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
static int count = 0;
public static void main(String[] args) {
while(true){
try{
if(count++ == 0)
throw new ThreeException();
System.out.println("No Exception");
} catch(ThreeException e){
System.err.println("Three Exception");
} finally {
System.err.println("In finally clause");
if(count == 2) break;
}
}
}
}
It prints:
Three Exception
In finally clause
In finally clause
No Exception
My question is why it doesnt print like this:
count = 0 -->
Three Exception
In finally clause
count = 1 -->
No Exception
In finally clause
count = 2 -->
No Exception
In finally clause
when count = 1 and 2 if statement doesn't excecute so it should print No Exception and then print the Finally
can someone explain it to me :)