• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compilation error

 
samdeep aarzoo
Ranch Hand
Posts: 160
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


on compilation i m getting error

Note.java:16: exception FrequencyException has already been caught
}catch(FrequencyException fe){
^
1 error

can anybody help to understand
[ July 17, 2005: Message edited by: Barry Gaunt ]
 
Girish Bal
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hi,

Here you are catching Exception first and then FrequencyException. That is why you are getting the compile time error. If you catch FrequencyException and then Exception, there won't be any compile error. This happens because FrequencyException extends Exception. So by catching Exception implicitly catches FrequencyException.

Am i right?
[ July 17, 2005: Message edited by: Girish Bal ]
 
Ramakrishna Nalla
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rule to remember:
All catch blocks must be ordered from most specific to most general. Simply we can say subclass exception first after that superclass exceptions we have to declare in catch block sequence...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic