Non static block - English

4720 visits



Outline:

Non-static block Any code written between two curly brackets Executed for each object that is created Executes before constructor's execution can initialize instance member variables of the class create a class named NonStaticTest Create a non-static block and a constructor inside it Check the output Include multiple non-static blocks they will be executed in the sequence in which they appear in the class Check the output Non-static block is not a substitute for constructor