question about throwing exceptions

hi,

i am trying to throw a FileNotFoundException in a certain situation, but Eclipse is giving me the 'unhandled FileNotFoundException' error and insisting I wrap the 'throw' statement in a try/catch statement.

Is that right? is it just a bug in eclipse or does this exception insist i catch the very exception i am trying to throw?

thanks!

[370 byte] By [pnandrusa] at [2007-10-2 21:05:23]
# 1

You can throw it, but you have to declare that your method throws it.

void myMethod() throws FNFExc {

throw new FNFExc("Me no findey");

}

jverda at 2007-7-13 23:50:41 > top of Java-index,Java Essentials,Java Programming...
# 2
If you want to throw an exception you have to say that you're throwing an exception :-)This is so that classes using this method know what to expect.
Norweeda at 2007-7-13 23:50:41 > top of Java-index,Java Essentials,Java Programming...
# 3
duh,yeah, i knew that! i am SO lame! =)i just kinda..you know... forgot!
pnandrusa at 2007-7-13 23:50:41 > top of Java-index,Java Essentials,Java Programming...
# 4
throw new StuffForgottenException ();
BIJ001a at 2007-7-13 23:50:41 > top of Java-index,Java Essentials,Java Programming...