Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can't understand the output

 
vaibhav srivastava
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Laxmikant Ruikar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are creating Excpetion object. You code is not throwing any excpection. So after try block, finally block is executing...

LDR
 
vaibhav srivastava
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks laxmi...
I just missed the obvious !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic