Throw in constructor

Hello

In a construtor of a class in an example, I found that

public MyClassName {

if (...)

throw new AnException //not runtime exeption

}

I wonder why in this constructor, I cannot find throws clause such as

public MyClassName throws AnException {

..

Please help -why, and if there is exception, what happen?

Regards

su

[394 byte] By [suhua] at [2007-11-27 4:14:13]
# 1
If that constructor is throwing a checked exception, then it must be declared in the c'tor's throws clause. If it's not, it will not compile.In other words, the situation you describe is not legal Java and will not compile.
jverda at 2007-7-12 9:20:34 > top of Java-index,Java Essentials,Java Programming...
# 2
ThanksI found out that the exception is an uncheck exceptionregards
suhua at 2007-7-12 9:20:34 > top of Java-index,Java Essentials,Java Programming...