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
Convert Character Array to IntStream in Java
Let’s say the following is our character array:
Character arr[] = { 'V', 'e', 'h', 'i', 'c', 'l' , 'e' };
To convert the above character array to IntStream
IntStream stream = Stream.of(arr).flatMapToInt(IntStream::of);
We have used the flatMapToInt() method for this.
The following is an example to convert character array to IntStream in Java:
Example
import java.util.stream.*;
public class Main {
public static void main(String[] args) {
Character arr[] = { 'V', 'e', 'h', 'i', 'c', 'l' , 'e' };
System.out.println("The character array = ");
for (char value : arr) {
System.out.println("Value = " + value);
}
IntStream stream = Stream.of(arr).flatMapToInt(IntStream::of);
System.out.println("\nCharacter Array to IntStream = ");
stream.forEach(System.out::println);
}
}
output
The character array = Value = V Value = e Value = h Value = i Value = c Value = l Value = e Character Array to IntStream = 86 101 104 105 99 108 101
Advertisements
