Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
Object and Primitive Arrays
This Java template lets you get started quickly with a simple one-page playground.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// {
import java.util.Arrays;
import java.util.stream.IntStream;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) {
// }
//Object Array
String[] array = {"t", "e", "c", "h", "i", "o"};
//Arrays.stream
Stream<String> stream1 = Arrays.stream(array);
stream1.forEach(x -> System.out.println(x));
//Stream.of
Stream<String> stream2 = Stream.of(array);
stream2.forEach(x -> System.out.println(x));
//Premitive Array
int[] intArray = {1, 2, 3, 4, 5};
//Arrays.stream
IntStream intStream1 = Arrays.stream(intArray);
intStream1.forEach(x -> System.out.println(x));
//Stream.of
Stream<int[]> tempStream = Stream.of(intArray);
IntStream intStream2 = tempStream.flatMapToInt(x -> Arrays.stream(x));
intStream2.forEach(x -> System.out.println(x));
//{
}
}
//}
Press desired key combination and then press ENTER.
Advanced usage
If you want a more complex example (external libraries, viewers...), use the Advanced Java template
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content