Skip to content

Instantly share code, notes, and snippets.

@tycoi2005
Created December 4, 2015 08:02
Show Gist options
  • Save tycoi2005/0ab85e767174b708c92e to your computer and use it in GitHub Desktop.
Save tycoi2005/0ab85e767174b708c92e to your computer and use it in GitHub Desktop.
import java.util.*;
import java.lang.*;
import java.io.*;
class TestStaticVariablePriority
{
public static void main (String[] args) throws java.lang.Exception
{
// System.out.println("a " + A.a);
System.out.println("b " + B.b);
// System.out.println("b " + B.b);
// System.out.println("a " + A.a);
}
}
class A {
public static Integer a =null;
static {
System.out.println("assign a");
a = 101;
}
}
class B {
public static Integer b = A.a;
static {
System.out.println("assign b, current " +b );
b = A.a;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment