0

I do not understand why the output for the following code. Confusion resides in the main method. I cannot see why "in main" is not printed first, even tough it is the first line to be read.

    class StaticSuper {

    static {
        System.out.println("super Static block");
    }

    StaticSuper() {

        System.out.println("SUper COntrductor");
    }
}

class StaticTest extends StaticSuper {

    static int rand;

    static {
        rand = (int) (Math.random() * 6);
        System.out.println("statick block  " + rand);
    }

    StaticTest() {

        System.out.println("constructor");
    }

    public static void main(String[] args) {

        System.out.println("in main");
        StaticTest ts = new StaticTest();

    }

}
eneko
  • 333
  • 4
  • 14

0 Answers0