有在ArrayList的2点覆盖的方法:为什么lst.add(2)为ArrayList <Long>给出编译错误而不是调用add(Long)方法?
公共布尔添加(E E)
公共无效加载(INT指数,E元件)
哪些一般规则,根据add(longArg)
无法打包并致电add(E e)
,给我编译错误(因此实际上禁止我从溢出呼叫到add(E e)
:
ArrayList<Long> lst = new ArrayList<>();
lst.add(2); // c.ERR, see below
// method add(int, Long) in the type ArrayList<Long>
// is not applicable for the arguments (int)
P.S. Eclipse(SE7)编译器。
因为它需要扩大和autoboxed增加,但它不会自动一举两得。 –
eclipse不是编译器 –
eclipse拥有自己的Java编译器实现,提供不同的错误信息,允许错误后继续编译.... –