• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Dan chisholm - Exceptions

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

This is a question from Dan chisholm question set.
The answer is Compile time error which I could not understand.

Why can't an exception be caught if its not thrown for sure ?
I was guessing that it may be because its a checked exception & we have'nt used 'throws' clause to specify that it might be thrown.



Thanks
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it is easier to see the compile time error that gets displayed.

exception BlueException is never thrown in body of corresponding try statement.

Mark
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As Mark says, please specify the compile error: We do not always have time to compile your code for you. However, since you are dealing with checked exceptions you should analyse your code to see whether both exceptions could actually be thrown. No BlueExceptions are declared to be thrown by the method m1, for example.
[ August 30, 2005: Message edited by: Barry Gaunt ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic