Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
    Bookmark Topic Watch Topic
  • New Topic

Awkward Question from Exception

 
Karan V Praba
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,
In the below Code,It suppose to throw an exception.Rather than its returning an value.I knew because of finally block.But what about the Exception which has thrown by the code ( Lable Throw Exception ),it suppose to be reaches the user,isn't it?.
Please expalin,where the thrown exception gone.
class TestingFinally
{

void int testingFinally() throws Exception{

try{
System.out.println("1");
throw new RuntimeException();//Lable Throw Exception

}catch(RuntimeException e){
System.out.println("2");
throw new Exception();

}catch(Exception e){
System.out.println("3");
throw new Exception();
}finally{
System.out.println("4");
return 10;
}

}



public static void main(String[] args) throws Exception
{
System.out.println("Hello World!");
System.out.println(new TestingFinally().testingFinally());
System.out.println("Hello World!");
}
}
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Report post to moderator
Topic closed as it has also been asked here in Java in General (advanced)
 
    Bookmark Topic Watch Topic
  • New Topic