O'Reilly logo

The Java® Language Specification, Java SE 7 Edition, Fourth Edition by Alex Buckley, Gilad Bracha, Guy Steele, Bill Joy, James Gosling

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 this15.8.3), to use the keyword super15.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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required