Reputation: 3969
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 ?
Upvotes: 7
Views: 225
Reputation: 2417
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
Upvotes: 1