Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to Map IntSteam to String object in Java
To Map IntStream to String object, use mapToObj and within that set the values −
.mapToObj(val -> "z" + val)
Before that, we used range() on IntStream −
IntStream.range(1, 10)
The following is an example to map IntStream to String object in Java −
Example
import java.util.stream.IntStream;
public class Demo {
public static void main(String[] args) throws Exception {
IntStream.range(1, 10)
.mapToObj(val -> "z" + val)
.forEach(System.out::println);
}
}
Output
z1 z2 z3 z4 z5 z6 z7 z8 z9
Advertisements
