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.7. Static Initializers

A static initializer declared in a class is executed when the class is initialized (§12.4.2). Together with any field initializers for class variables (§8.3.2), static initializers may be used to initialize the class variables of the class.

StaticInitializer:    static Block

It is a compile-time error if a static initializer cannot complete normally (§14.21).

It is a compile-time error if a return statement (§14.17) appears anywhere within a static initializer.

It is a compile-time error if the keyword this15.8.3) or the keyword super15.11, §15.12) or any type variable declared outside the static initializer, appears anywhere within a static initializer.

Use of class variables whose declarations appear textually ...

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