Anonymous Block


Anonymous Block

Is a convenience provided to java developers to define statements common to all constructors of a class. At the time of compilation statements of anonymous block are moved at the beginning of each constructor by the compiler.




OR

 The same program we can also write like this:



















No comments:

Post a Comment