Advertisement

Udemy WW Udemy WW

Monday, 28 November 2011

Can we execute static block without main()

YES....static block can  execute without main() if we are using previous version of JDK
It will not supported by JDK 7..
class Demo
{
static{
System.out.println("helllo.....");
System.exit(0);
}
}
static block will execute if we compile and interpret above code with previous version of JDK (not supported by jdk7)


2 comments:

Advertisement

Udemy WW