Created
December 4, 2015 08:02
-
-
Save tycoi2005/0ab85e767174b708c92e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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