Initializing Data Members : Initialization Block « Class Definition « Java Tutorial

public class MainClass {
  static final double PI = 3.14;          // Class variable that has a fixed value
  static int count = 0;                   // Class variable to count objects

  public void aMethod() {


5.11.Initialization Block
5.11.1.A class that contains a static initializer:
5.11.2.Initializing Data Members
5.11.3.Initialization order
5.11.4.Using Initialization Blocks: A non-static initialization block
5.11.5.Using Initialization Blocks: static initialization block
5.11.6.Mixed Initializer
5.11.7.Explicit static initialization with the static clause
5.11.8.The full process of initialization
5.11.9.Demonstrates various initializers
5.11.10.Demonstrates the pitfalls of depending on the order of static initializers