Sunday, 25 August 2013

Deciphering Generics Syntax

Deciphering Generics Syntax

I am reading through a question where the signature of the method is given
below
public static <E extends CharSequence> List<? super E> doIt(List<E> nums)
I am unable to decode the syntax. I am very fresh in generics and unable
to understand this part. Doesn't the first part <E extends CharSequence>
tells what E should be, both for as an argument and as a return type. But
i do see List<? super E>, this defines the bounds for the return type. Can
someone help me understand this with an example?
Thanks.

No comments:

Post a Comment