Using Static Initializers to assign value to static variable - Java Object Oriented Design

Java examples for Object Oriented Design:Static

Introduction

A static initializer that's designed specifically to let you initialize static fields.

The general form of a static initializer is this:

static
{
   statements...
}

Here's an example of a class that contains a static initializer:

class StaticInit
{
   public static int x;

   static
   {
      x = 32;
   }

}

Related Tutorials