Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
SCJP 6.0 96%
(Connecting the Dots ....)
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
F:\Java\Javaranch problems>javac MyException.java
MyException.java:9: exception MyException is never thrown in body of correspondi
ng try statement
catch (MyException me){
^
MyException.java:19: unreported exception MyException; must be caught or declare
d to be thrown
throw me;
^
2 errors
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
SCJP 6.0 96%
(Connecting the Dots ....)
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Bert Bates wrote:
First off, you're correct about the two approaches you could take in main(), handle or declare... hooray!
Now the question I have for you is this:
Assuming that you're not going to change doStuff(), and that it's all about what you do in main(), what are the implications of these two approaches?
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Implications? Wow, let me guess...
I'm thinking modularity, especially if there are a team of programmers. If one person is writing main() and the other is writing doStuff(), how does the person who is writing main() know that the person writing doStuff() will handle the exception, i.e. without throwing it back?
Can you give me a hint?
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Bert Bates wrote:Hey Sandra,
You said:
Implications? Wow, let me guess...
I'm thinking modularity, especially if there are a team of programmers. If one person is writing main() and the other is writing doStuff(), how does the person who is writing main() know that the person writing doStuff() will handle the exception, i.e. without throwing it back?
Can you give me a hint?
Sorry, let me be more specific:
First off, there is a mistake in what you just said... Tell me this, how *would* the guy writing main() "know" what doStuff() might do? Hmmm....
Second, if you're writing main(), what's acceptable behavior for main()? For instance it might be acceptable for a main() that's used during testing to behave differently than a main() that's meant for a final application...
Does that help?
Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
It was the best of times. It was the worst of times. It was a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|