Understand declaration of a terminal operation method -


usually, method's declaration shows return type, method full path, , parameters. when @ method java.util.stream.stream.collect confused.

it seems method has two return types:

<list<integer>, object> list<integer> java.util.stream.stream.collect(collector<? super integer, object, list<integer>> collector) 

i understand real return type list<integer>, <list<integer>, object> mean? why 1 space before list<integer> , why key(if map?) same real return type?

have @ declaration of method:

public interface stream<t> extends basestream<t, stream<t>> {     ...     /* ...      * @param <r> type of result      * @param <a> intermediate accumulation type of {@code collector}      * ...      */     <r, a> r collect(collector<? super t, a, r> collector);     ... } 

as nathan pointed out in comments, <r, a> denotes generic type parameters. these inferred java compiler long unambiguous. in case r inferred list<integer> , a object. can read here generic methods.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -