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.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlEuUdkjOKJsjINV_U5kKoddDbEzyShoRac-UASm4_lK0tgpmXb3ol4Xb7Q6F04YZRoDJ_cpaJOTfL39bdPYeJ9SYSdZAjlfos1xaYzF9r2HBqelBIWjaGHuT8TnRpM06uuMQV9CYFL3DJ/s1600/uptuexam_core_java.png)
OR
The same program we can also write like this:
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxpdxHej8jE_ZOKI4Se6MZbCkjsxoYBhwI0F9meF4qaUl1cVJs-vCLBcylUO4jUEffJra9rwnSImnPagOU5PXZfpjLl58YUTNuTtVuQ7WEDJTOPXiOO1SGbEwxPnVIf9LmZJnpW9HyyPHJ/s1600/uptuexam_core_java.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjF2MstWITlTGlU506gYhFCS3IMPicdDZ3QpKDF8ioRyG-8VxjyRtJURCbjdxL2iZnMLYpw0z5GgFFoHu-lhbf3pcORJGRNmiKg9EKEDGk-v6ZUdVhmuf6AxVw7VbyqGJ1OYdj4qPxsvtSH/s1600/uptuexam_core_java.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguXMjJ1sr24TQXloZOakL96OApiZ31oujbTL9Am70v949SrmMq1yqDAh4hWMCWXzFH2T-OP4hVgZWIMGwZZyHTXMtzaq3XuiKtI17xjYGYOZbKXxxp0wHXT749RKyWA5ngKHgM3R3LSqK-/s1600/uptuexam_core_java.png)
No comments:
Post a Comment