Close

Java 8 Streams - DoubleStream.mapToInt Examples

Java 8 Streams Java Java API 


Interface:

java.util.stream.DoubleStream

java.lang.AutoCloseableAutoCloseablejava.util.stream.BaseStreamBaseStreamjava.util.stream.DoubleStreamDoubleStreamLogicBig

Method:

IntStream mapToInt(DoubleToIntFunction mapper)

This terminal operation returns an IntStream consisting of the results of applying the given function to the elements of this stream.


Examples


package com.logicbig.example.doublestream;

import java.util.stream.DoubleStream;
import java.util.stream.IntStream;

public class MapToIntExample {

public static void main(String... args) {
DoubleStream ds = DoubleStream.of(1.0, 1.2, 2.0, 2.4, 3.0);
IntStream intStream = ds.mapToInt(Math::getExponent);
intStream.forEach(System.out::println);
}
}

Output

0
0
1
1
1




See Also