35,327 views
44 votes
44 votes
Stream method ________ maps objects to double values and returns a DoubleStream. The method receives an object that implements the functional interface ToDoubleFunction (package java.util.function).

User Chuck Wilbur
by
3.2k points

1 Answer

24 votes
24 votes

Answer:

mapToDouble()

Step-by-step explanation:

The method being described is the mapToDouble() method. This is a method that is built into a pre-defined Java package. This function takes in another function as a parameter to perform on a set of values. This is why the stream().mapToDouble() function is usually called on a list of values. The outputs will be a list of Double type values. An example of this would be the following code which takes in a list of strings and divides their length by 2 and maps them as Doubles. Which will output a list of double values.

list.stream().mapToDouble(str -> str.length() / 2)

.forEach(System.out::println);

User Running Buffalo
by
2.9k points