Answer the question
In order to leave comments, you need to log in
How to understand a strange generic?
Hello. Please explain what the following generic entry means
public static <I, O> List<O> map(Stream<I> stream, Function<I, O> mapper)
Answer the question
In order to leave comments, you need to log in
The phenomenon is called data type. In this case, this function returns a hash table with key-value pairs: keys are "I", values are "O". The weird thing here is that it's just a hash table, so you can access its element by calling its key of type I, rather than just by element number as in a normal array.
is used to declare that a method is a generic method, the enumerated types will be used in the signature or in the body of the method.
this means that the function takes as arguments a Stream of type I and a Function of type I and O, returns a List of type O
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question