IntStream mapToObj() in Java Last Updated : 19 Sep, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report IntStream mapToObj() returns an object-valued Stream consisting of the results of applying the given function. Note : IntStream mapToObj() is a intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output. Syntax :<U> Stream<U> mapToObj(IntFunction<? extends U> mapper)Parameters : U : The element type of the new stream.Stream : A sequence of elements supporting sequential and parallel aggregate operations.IntFunction : Represents a function that accepts an int-valued argument and produces a result. mapper : A stateless function to apply to each element.Return Value : The function returns an object-valued Stream consisting of the results of applying the given function. Example 1 : Java // Java code for IntStream mapToObj // (IntFunction mapper) import java.util.*; import java.util.stream.Stream; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream IntStream stream = IntStream.range(3, 8); // Creating a Stream of Strings // Using IntStream mapToObj(IntFunction mapper) // to store binary representation of // elements in IntStream Stream<String> stream1 = stream.mapToObj(num -> Integer.toBinaryString(num)); // Displaying an object-valued Stream // consisting of the results of // applying the given function. stream1.forEach(System.out::println); } } Output : 11100101110111Example 2 : Java // Java code for IntStream mapToObj // (IntFunction mapper) import java.util.*; import java.math.BigInteger; import java.util.stream.Stream; import java.util.stream.IntStream; class GFG { // Driver code public static void main(String[] args) { // Creating an IntStream IntStream stream = IntStream.of(3, 5, 7, 9, 11); // Creating a Stream // Using IntStream mapToObj(IntFunction mapper) Stream<BigInteger> stream1 = stream .mapToObj(BigInteger::valueOf); // Displaying an object-valued Stream // consisting of the results of // applying the given function. stream1.forEach(num -> System.out.println(num.add(BigInteger.TEN))); } } Output : 1315171921 Comment More infoAdvertise with us Next Article IntStream mapToDouble() in Java S Sahil_Bansall Follow Improve Article Tags : Java Practice Tags : Java Similar Reads IntStream mapToDouble() in Java IntStream mapToDouble() returns a DoubleStream consisting of the results of applying the given function to the elements of this stream. Note : IntStream mapToDouble() is a intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after the 2 min read Map Interface in Java In Java, the Map Interface is part of the java.util package and represents a mapping between a key and a value. The Java Map interface is not a subtype of the Collections interface. So, it behaves differently from the rest of the collection types.Key Features:No Duplicates in Keys: Keys should be un 11 min read How to Iterate Any Map in Java? In Java, a Map is a data structure that is used to store key-value pairs. Understanding how to iterate over the elements of a map plays a very important role. There are 5 ways to iterate over the elements of a map, and in this article, we are going to discuss all of them.Note: We cannot iterate over 5 min read IntStream flatMap(IntFunction mapper) in Java IntStream flatMap(IntFunction mapper) returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element. This is an intermediate operation. These operations are always lazy. Inte 2 min read Integer toString() in Java The java.lang.Integer.toString() is an inbuilt method in Java which is used to return the String object representing this Integer's value. Syntax : public static String toString() Parameters: The method does not accept any parameters. Return Value:The method returns the string object of the particul 5 min read IntStream map(IntUnaryOperator mapper) in Java IntStream map(IntUnaryOperator mapper) returns a stream consisting of the results of applying the given function to the elements of this stream. This is an intermediate operation. These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their p 2 min read Like