如果你编译这段代码,首先你会看到一个警告:
Note: Example.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
在编译器标记中增加-Xlint:unchecked,你会发现它在列表中增加了一个Integer类。
Example.java:41: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
list.add(new Integer(1000));
Example.java:42: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
list.add(new Integer(200));
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/