public <E extends Foo> List<E> getResult(String s);
where Foo is my own class.
Foo
What is the return type of this method? Why does it seem to have two return types?
No, you don't have two return types.It's a generic method you are seeing.
<E extends Foo> --> you are declaring a generic type for your method List<E> --> this is your return type
Your method can have a generic type E which is a sub-class of Foo. your return type is a List<Foo or any SubType Of FOO>
E
List<Foo or any SubType Of FOO>
2.1m questions
2.1m answers
60 comments
57.0k users