Thursday, October 15, 2015

Understanding mysterious static - 1

package teststatic;
public class InterestingStatic1 {
        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

1 comment:

  1. Static part will execute first when program gets loaded by JVM to run