1.为什么第一个打印语句为null,第二个打印语句为perfect?
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
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
The execution has not been completed, so NAMES has not yet become a reference to this "ArrayList", so it is null