• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Exception Handling

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class TestClass3
{
public static void main(String args[])
{
int k = 0;
try{
int i = 5/k;
}
catch (ArithmeticException e){
System.out.println("1");
//return;
}
catch (RuntimeException e){
System.out.println("2");
return ;
}
catch (Exception e){
System.out.println("3");
}
finally{
System.out.println("4");
}
System.out.println("5");
}
}
The output is 145, but if return is uncommented in catch the output is 14. can anyone explain the difference in output if Try/Catch returns.

-Arun
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried answering that question in this thread.
-anthony
 
Arun Pai
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Anthony.
-Arun
 
Get me the mayor's office! I need to tell her about this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic