File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes can't understand the output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "can Watch "can New topic
Author

can't understand the output

vaibhav srivastava
Greenhorn

Joined: Feb 24, 2008
Posts: 14
public class main{
public static void main(String[] args){
try {
new Exception();
}catch(Exception e) {
try {
System.out.println("1");
new Exception();
}
catch(Exception f) {
System.out.println("2");
}
finally {
System.out.println("finally 1");
}
}
finally {
System.out.println("finally 2");
}
}
}


output
finally 2


A computer once beat me at chess, but it was no match for me at kick boxing.<br />
Laxmikant Ruikar
Greenhorn

Joined: Nov 29, 2005
Posts: 23
You are creating Excpetion object. You code is not throwing any excpection. So after try block, finally block is executing...

LDR
vaibhav srivastava
Greenhorn

Joined: Feb 24, 2008
Posts: 14
thanks laxmi...
I just missed the obvious !!!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: can't understand the output
 
Similar Threads
help, flowing program
Exception
exception..try catch block execution
Exception
PLease Explain Below Output