Win a copy of Learning Java by Building Android Games this week in the Android forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Devaka Cooray
Saloon Keepers:
  • Ganesh Patekar
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • salvin francis
Bartenders:
  • Ron McLeod
  • Frits Walraven
  • Pete Letkeman

Exceptions  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one able to explain the below code why the output came abce followed by exception instead of abcde followed by exception???

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some extra info, I found this code in the book written by Jeanne Boyarsky and Scott Selikoff on page 332 in chapter 6.
 
Ranch Hand
Posts: 225
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since you already know the output, the specifics are:
IllegalArgumentException thrown on line 8  is caught on line 9
RuntimeException  thrown on line 11  isn't caught;  line 11 is not "guarded" inside its own try and catch)
line 16 executes inside the finally because the finally always executes (unless System.exit(0) and/or JVM shuts down)
RuntimeException  thrown on line 17 inside the finally is never caught

 
Charles O'Leary
Ranch Hand
Posts: 225
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
 
Charles O'Leary
Ranch Hand
Posts: 225
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Charles O'Leary wrote:Since you already know the output, the specifics are:
IllegalArgumentException thrown on line 8  is caught on line 9
RuntimeException  thrown on line 11  isn't caught;  line 11 is not "guarded" inside its own try and catch)
line 16 executes inside the finally because the finally always executes (unless System.exit(0) and/or JVM shuts down)
RuntimeException  thrown on line 17 inside the finally is never caught


My apologies for the re-numbering:
Untitled.png
[Thumbnail for Untitled.png]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!