本帖最后由 hacket 于 2013-3-12 20:46 编辑
- public class TestStaticCode {
- private static TestStaticCode tsc = new TestStaticCode();
- static{
- System.out.println("4");
- }
- private InstanceVariable iv = new InstanceVariable();
-
- private TestStaticCode(){
- System.out.println("3");
- }
- public static void main(String[] args){
- }
- }
- class InstanceVariable {
- static{
- System.out.println("1");
- }
- public InstanceVariable(){
- System.out.println("2");
- }
- }
复制代码 运行结果怎么是这个:
1
2
3
4
|