package teststatic;
public class InterestingStatic1 {
static{
System.out.println("In static block...InterestingStatic1");
}
public static void
main(String[] args) {
System.out.println("In main...InterestingStatic1");
}
}
What do you think should be the output. Normal understanding
is main is executed first by JVM. Run this code. Do you find something
unexpected?
More interesting code … tomorrow… let the mystery of static
be resolved slowly, so that you enjoy…
©K.A.N. Nancy
Static part will execute first when program gets loaded by JVM to run
ReplyDelete