Exception

Hi,I would like to know in java, how can we pre determine the exceptions that can be thrown by a method?i.e if we just mention method throws exception , is there any performance impact for the application?Siva
[237 byte] By [SB_KANNANa] at [2007-11-26 19:05:37]
# 1
Those seem to be two different and unrelated questions.
DrLaszloJamfa at 2007-7-9 20:56:01 > top of Java-index,Java Essentials,New To Java...
# 2
Ok. Thanks..I would like to know the answer for my second question..if we just mention method throws exception (without being more specific) , is there any performance impact for the application?RgdsSiva
SB_KANNANa at 2007-7-9 20:56:01 > top of Java-index,Java Essentials,New To Java...
# 3
I don't think there is a performance problem (as in, your code won't run any slower). The main problem is when you use a try catch with just Exception, because the feedback from the program isn't going to be detailed enough to help you debug it.
abu5ea at 2007-7-9 20:56:01 > top of Java-index,Java Essentials,New To Java...
# 4

When we ran some tools for performance for code review, it shows that exception should be specific wherever we declare..In some code there may be thousands of methods that does not mention thowing specific exceptions...

In best practices of using exceptions it has been said that when we declare a method capable of throwing an exception we need to mention more specific exception...If there is no performance impact, why it has been recommended in best practices ?

SB_KANNANa at 2007-7-9 20:56:02 > top of Java-index,Java Essentials,New To Java...
# 5
Sounds like a homework question you need to answer not us.
floundera at 2007-7-9 20:56:02 > top of Java-index,Java Essentials,New To Java...
# 6

> If there is no performance

> impact, why it has been recommended in best practices

> ?

Not everything revolves around performance, especially when it comes to best practices. Just looking up "best practices" on wikipedia should get you started with answering this question.

bheilersa at 2007-7-9 20:56:02 > top of Java-index,Java Essentials,New To Java...