Monday, 1 April 2013

static block in Java

Leave a Comment
which holds piece of code to executed when class is loaded in Java. This is also known as static initialize block as shown in below example.

static {
        String category = "electronic trading system";
        System.out.println("example of static block in java");

Beware that if your static initialize block throws Exception than you may get java.lang.NoClassDefFoundError when you try to access the class which failed to load. 


Post a Comment