为什么自动装箱在 eclipse 中起作用,但在 javac 中不起作用?
此代码:
Integer ints[] = new Integer[]{'1', '2', '3'};
在 eclipse 中编译得很好,但是 javac(版本 1.6.0_27 和 1.7.0)给出了以下错误:
BoxTest.java:4: incompatible types
found : char
required: java.lang.Integer
Integer ints[] = new Integer[]{'1', '2', '3'};
BoxTest.java:4: incompatible types
为什么?
我假设它是某种编译器标志,但是挖掘槽日食来弄清楚它并不完全是直截了当的。