public <S extends CharSequence> S foo(S s){
return null;
}
I found this method in one of the OCJP question. But I find it difficult to understand what exactly the return type <S extends CharSequence> S means. Could someone having knowledge in Java explain me what it means?
The definition
<S extends CharSequence>means thatSis a type that extends or implementsCharSequence.Note the presence of
Sbeforefooand after it. This means thatfooreturns a type that either extends or implementsCharSequence, and accepts an argument of the same type.