In Effective Java J. Bloch mentioned that it was not safe to use varargs method with primitive types. Percisely, Arrays.asList(1, 2, 4)
had return type List<int[]>
and it sounds quite reasonble. Now I tried to reproduce this behaviour myself and couldn't:
My question is why is the type deduced to List<Integer>
but not to List<int[]>
as he stated? Does it mean, that in Java 8 the problem about varargs is not relevant anymore and we can safely use them anywhere we want if we don't care about performance too much.