2016-01-27 12 views

risposta

23

Il IntStream class's map method mappe int s a più int s, con un IntUnaryOperator (int a int), non oggetti.

In genere, il metodo map di tutti i flussi associa il tipo di flusso a se stesso e le mappe mapToXyz a un tipo diverso.

Provare invece il mapToObj method, che prende un IntFunction (int per oggetto).

.mapToObj(id -> new MyObject(id)); 
+4

Oppure '.mapToObj (MyObject :: new)' ... – Holger

Problemi correlati