开发者

What is erasure

What is erasure and what is the restrictions of erasure on 开发者_C百科generics?


Erasure is the result of types being used at compile time and not being present at runtime. This is a common issue in Java Generics. The main issue is that at runtime you are unable to determine the type a generic class contains. For example if you have

ArrayList<Foo> t;

It is not possible to get the type, Foo, the ArrayList contains using reflection at runtime.


Here is a good explanation: http://download.oracle.com/javase/tutorial/java/generics/erasure.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜