Mandroid
Mandroid

Reputation: 7468

Java type erasure: How is type safety ensured?

As per type erasure mechanism in Java generics, a method:

boolean add(E e);

..gets compiled to

boolean add(Object e);

But then how is type safety ensured? As add now takes Object, I can pass String, Integer, Employee etc as all are sub-types of Object.

Upvotes: 0

Views: 16

Answers (0)

Related Questions