Above code is initialization block. initialization blocks run when new instance is created. In your code there is not any instance of Test so initialization block will never executed. create new instance of Test in your code and initialization block will be executed. Semicolon at the end of class is optional.