Does Java 1.4 have generics?

和自甴很熟 提交于 2020-01-05 03:59:11

问题


Looking at some old code in Java 1.4 but I'm unfamiliar with Java.

Does Java 1.4 have generics? I've been looking through the code and haven't found any uses of generics, but that doesn't necessarily mean they aren't supported.


回答1:


No, that was a 1.5 introduction. (That is, "Java 2 release 1.5". There was the really old version 1.4 that was the farthest the Microsoft JVM got.)




回答2:


No. Generics have been introduced with J2SE 5.0 (aka "Java 1.5", aka "Tiger").

Wikipedia has details on all changes.




回答3:


No, Java 1.4 does not have Generics. As already indicated by others, it got introduced in 1.5. However, you can have a mixture of generic and non generic code for backward compatibility. This is possible because generic (or type safety) is a compile time event for JVM. On runtime the "eraser" removes all the type safety information and the type safe code becomes the plane old non type safe one.




回答4:


Nope, didn't come along until Java 5.

However, the apache commons library has some useful stuff such as the TypedCollection decoration which can help you if your stuck on an old version of Java.

http://commons.apache.org/collections/



来源:https://stackoverflow.com/questions/4146197/does-java-1-4-have-generics

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!