File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,17 @@ see the [Scala Collections Guide](https://docs.scala-lang.org/overviews/collecti
81
81
82
82
[ answer on Stack Overflow] ( https://stackoverflow.com/a/5598107 )
83
83
84
+ ### Why do primitive type parameters erase to ` Object ` ?
85
+
86
+ So for example, a ` List[Int] ` in Scala code will appear to Java as a
87
+ ` List[Object] ` . The Java type system doesn't allow primitive types to
88
+ appear as type parameters, but couldn't they appear as their boxed
89
+ equivalents, such as ` List[java.lang.Integer] ` ?
90
+
91
+ One would hope so, but doing it that way was tried and it proved
92
+ impossible. [ This SO question] ( https://stackoverflow.com/questions/11167430/why-are-primitive-types-such-as-int-erased-to-object-in-scala )
93
+ sadly lacks a concise explanation, but it does link to past discussions.
94
+
84
95
## More questions
85
96
86
97
{% assign overviews = site.overviews | sort: 'num' %}
You can’t perform that action at this time.
0 commit comments