A boxing conversion needs to be applied here, because lists contain boxed primitives, not primitives.
This conversion is described in JLS Sec 5.1.7:
Boxing conversion converts expressions of primitive type to corresponding expressions of reference type. Specifically, the following nine conversions are called the boxing conversions:
- ...
- From type int to type Integer
- From type long to type Long
- ...
But there is no boxing conversion "from int to type Long". As such, this method invocation cannot be applied, and so it's a compiler error.
Either explicitly cast to long
, explicitly box using Long.valueOf(intValue)
(in which a widening conversion converts the int
parameter to a long
), or use the L
suffix on a literal.