user739061
user739061

Reputation: 21

What is erasure

What is erasure and what is the restrictions of erasure on generics?

Upvotes: 2

Views: 209

Answers (2)

linuxuser27
linuxuser27

Reputation: 7353

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.

Upvotes: 3

IAmTimCorey
IAmTimCorey

Reputation: 16757

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

Upvotes: 1

Related Questions