Stream super convenient. Stream Justice, and Stream forget soon. So I made a cheat sheet. Thank you for your consideration.
Arrays.asList("honto", "world", "tough").stream().forEach(s -> System.out.println(s));
Arrays.asList("Seriously", "really", "tough").stream().forEach(System.out::println);
Collections.emptyMap().entrySet()
.forEach(e -> System.out.println(e.getKey() + ":" + e.getValue()));
Arrays.asList("love", "Love", "Money", "dream").stream()
.filter(s -> s.equals("Love")).forEach(System.out::println);
Arrays.asList("1", "2", "3", "5").stream()
.map(s -> Integer.valueOf(s)).forEach(System.out::println);
IntStream.range(0, 10).map(i -> i*2).toArray();
Arrays.asList("SU-METAL DEATH!", "YUIMETAL DEATH!", "MOAMETAL DEATH!").stream()
.map(s -> s.split(" ",2)).filter(a -> 2 == a.length)
.collect(Collectors.toMap(a->a[0], a->a[1]));
Arrays.asList("love", "Love", "Money", "dream").parallelStream()
.findFirst(s -> s.equals("Love"));
Arrays.asList("Love,that is,Sweet","Love,that is,strongly","Love,that is,Noble").stream()
.map(s -> s.split(",")).flatMap(a -> Arrays.asList(a).stream())
.collect(Collectors.toList());
Function<String, String> toHakata = s -> {
return s + "Toyo.";
};
Arrays.asList("Sogyan Kotsunaka").stream().map(toHakata);
Please comment and pull request.
Recommended Posts