File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes compilation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "compilation error" Watch "compilation error" New topic

compilation error

samdeep aarzoo
Ranch Hand

Joined: Jun 09, 2005
Posts: 160

on compilation i m getting error 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

Joined: Jun 23, 2005
Posts: 77


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 ]

Girish B
SCJA 1.0 (86%)
SCJP 1.4 (91%)
Ramakrishna Nalla
Ranch Hand

Joined: Apr 21, 2005
Posts: 61
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:
subject: compilation error
It's not a secret anymore!