Hello,
I'm new to Java and I found out that I sometimes do mistake missing try/catch blocks. I'm working on Eclipse. Just now I've finished a program but I'm wondering if I put all try/catch. Is there a way to check it? (tricks, maybe with ecplipse?).
What do you suggest in general or in this case?
thanks,,,


Reply With Quote

In general, you can't "miss" an exception, you have to handle it one way or another (catch it or pass it on to a higer level), otherwise the compiler will complain. There are, however, unchecked exceptions (those derived from RuntimeException, for which Java does not enforce these rules. I guess the one you missed was of this kind. To catch and handle those, study the documentation of the classes you use. The exceptions that could be thrown should be mentioned there. But in the end, you still have to decide where and how to handle an exception.

Bookmarks