please see above picture (from Wrox Beginning Spring book)
I have this question that what is { } ?
Is constructor ? Is functional block ? Is block of "accountsMap" ? What is it ?
please explain this feature in java ? what is the name of this feature ?
It's an instance initializer block which gets executed each time you create an instance of the class, no matter which constructor is used. It is executed prior to the code of the executed constructor. See JLS 8.6 for more details.
That's an instance initializer block. Whenever a new instance of any class is created, code inside these braces gets executed prior to constructor invokation. http://www.javatpoint.com/instance-initializer-block
General sequence of blocks execution.
1- Static initializer block (Invoked when class is loaded)
And when new instance is created
2- Instance initializer block
3 - Constructor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With