i want to throw checked exception from a static block, when i tried that the following compilation error arises:
error: unreported exception Exception; must be caught or declared to be thrown
my static code block is as follows:
static{
if(something)
doSomething();
else
throw new Exception("Checked Exception from static block");
}
IF this is not allowed in java, what work around can i do to throw a checked exception from a static block,in other word, how can i do that before the main method is called? thanks.