In static initiliazer we can't throw Checked Exceptions.
am i right?
Thanks Anil Kumar
Joined: Feb 28, 2007
In static initiliazer we can't throw Checked Exceptions. am i right?
Static initializer must complete normally. As Barry gave an example that if instance initializer throws a checked exception the constructor must declare that exception to be caught. In case of static initializer, you can place the code that may throw exception in the try catch block. Like:
Instance init block also can't throw checked exception until you handle it or declare it in the constructor.