Java 8 Streams Java Java API
Interface:
java.util.stream.IntStream
Method:
<U> Stream<U> mapToObj(IntFunction<? extends U> mapper)
This intermediate operation returns an object-valued Stream consisting of the results of applying the given mapper function to the elements of this stream.
Examples
package com.logicbig.example.intstream;
import java.math.BigInteger; import java.util.stream.IntStream; import java.util.stream.Stream;
public class MapToObjExample {
public static void main(String... args) { IntStream intStream = IntStream.range(1, 5); Stream<BigInteger> stream = intStream.mapToObj(BigInteger::valueOf); stream.forEach(b -> System.out.println(b.multiply(BigInteger.TEN))); } }
Output10 20 30 40
|