开发者

What is erasure

开发者 https://www.devze.com 2023-03-02 18:15 出处:网络
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 Jav

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

精彩评论

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