StaticConstructor.java 373 Bytes
Newer Older
Andrew Haley committed
1
// Test to make sure static initializers are called
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

class bar
{
  public static int zog;
  public static int zag;

  static
  {
    zog = 12;
    zag = 2;
  }

  public bar() { } 
}

public class StaticConstructor
{
  static int foo ()
  {
    return new bar().zog;
  }

  public static void main(String args[])
  {
    System.out.println ("" + (foo() + bar.zag));
  }
}