The Java® Language Specification, Java SE 7 Edition, Fourth Edition
by James Gosling, Bill Joy, Guy Steele, Gilad Bracha, Alex Buckley
8.6. Instance Initializers
An instance initializer declared in a class is executed when an instance of the class is created (§12.5, §15.9, §8.8.7.1).
InstanceInitializer: Block
It is a compile-time error if an instance initializer cannot complete normally (§14.21).
It is a compile-time error if a return statement (§14.17) appears anywhere within an instance initializer.
Instance initializers are permitted to refer to the current object via the keyword this (§15.8.3), to use the keyword super (§15.11.2, §15.12), and to use any type variables in scope.
Use of instance variables whose declarations appear textually after the use is sometimes restricted, even though these instance variables are in scope. See §8.3.2.3 for the precise rules governing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access