java基础知识,题目描述如图所示
巴扎黑
巴扎黑 2017-04-18 10:24:57
0
2
315

1.为什么第一个打印语句为null,第二个打印语句为perfect?

巴扎黑
巴扎黑

reply all(2)
Peter_Zhu

When executing the anonymous inner class, the reference of “ArrayList” has not been assigned to NAMES

黄舟

The first sentence of System.out.println(NAMES), the code block

new ArrayList<String>() {{
    add("prefect");
    System.out.println("init: " + NAMES); 
}};

The execution has not been completed, so NAMES has not yet become a reference to this "ArrayList", so it is null

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template