The java.util.stream is a sequence of elements supporting sequential and parallel aggregate operations.
Java 8 create stream using list example
package com.w3spoint;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
public class Test{
public static void main(String[] args) {
List<String> names = Arrays.asList("Vishal","Naren");
Stream<String> namesStream = names.stream();
namesStream.forEach(System.out::println);
}
} |
package com.w3spoint; import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream; public class Test{
public static void main(String[] args) {
List<String> names = Arrays.asList("Vishal","Naren");
Stream<String> namesStream = names.stream();
namesStream.forEach(System.out::println);
}
}
Output