Hacker News new | past | comments | ask | show | jobs | submit login

That's because List is an interface, not a class. FYI this works in Scala:

val j = List(1, 2, 3)




It 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.


However 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.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: