Content deleted Content added
m Add reference for to show that .NET generics do not apply type erasure |
m Add inline citation. Add link to JVM. |
||
Line 377:
{{Main article|Generics in Java}}
Support for the ''generics'', or "containers-of-type-T" was added to the [[Java (programming language)|Java programming language]] in 2004 as part of J2SE 5.0. In Java, generics are only checked at compile time for type correctness. The generic type information is then removed via a process called [[type erasure]], to maintain compatibility with old [[Java virtual machine|JVM]] implementations, making it unavailable at runtime.<ref>''Effective Java: Programming Language Guide'', third edition: {{ISBN|978-0134685991}}, 2018, p.126</ref> For example, a <code>List<String></code> is converted to the raw type <code>List</code>. The compiler inserts [[Type conversion|type casts]] to convert the elements to the <code>String</code> type when they are retrieved from the list, reducing performance compared to other implementations such as C++ templates.
====Genericity in .NET [C#, VB.NET]====
|