4 ms·
That's because List is an interface, not a class. FYI this works in Scala: val j = List(1, 2, 3)
by Nutomic 11y ago
That's because List is an interface, not a class. FYI this works in Scala:
val j = List(1, 2, 3)
- duaneb 11y agoIt doesn't work for all scala interfaces, and when it is like that, it's often frustrating to find the underlying implementation. But that's beside the point—OP was pointing out that you can't have generic allocation.
- merb 11y agoHowever there are mostly alternatives for Java8 something like that: Collections.singletonList(1, 2, 3) which actually gives a List<Int> by the end it all comes down to syntactic sugar.