Elad Benda
Elad Benda

Reputation: 36654

java error both methods have same erasure for generics

I have an interface with these two methods.

E2EResult sendRoutingRequests(List<RoutingRequest> routingRequestsList);

E2EResult sendRoutingRequests(List<String> routingRequestsList);

The compiler shouts for:

java error both methods have same erasure

I saw some posts talking about same erasure for java generics.

Can someone explain why is that?

It's different q than this post, because I don't deal with wild card.

Upvotes: 7

Views: 3802

Answers (1)

Eran
Eran

Reputation: 393821

The compiler removes the generic type parameters, so List<String> and List<RoutingRequest> become List, and thus both methods have the same signature.

Upvotes: 5

Related Questions