This time it is Stream. Sample immediately.
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**
*Studying Stream. Int stream.
* @author komikcomik
*
*/
public class StreamSample {
public static void main(String[] args) {
//It's like creating a stream and having it do a series of processes inside
IntStream is = IntStream.of(1000, 123, 456, 1001, 10000, 919, 561, 2000);
//Extract over 1000 data, sort, then standard output
is.filter(i -> i >= 1000).sorted().forEach(i -> System.out.println(i));
//Remove non-single character data → sort → standard output
Stream<String> strStream = Stream.of("A", "b", "C", "d", "AAA", "BBB", "E");
strStream.filter(s -> s.length() == 1).sorted().forEach(s -> System.out.println(s));
}
}
Execution result
1000
1001
2000
10000
A
C
E
b
d
The image was easy to get rid of, but it seems to be quite a problem if I ask if this can be used at the site of pounding.
Recommended Posts