It's been quite a while since Java 8 came out, but it seems that there are quite a lot of people who do not know how to write lambdas. A guy who uses lambda as a memorandum to Sysout the alphabet Feeling using basic For Each and sorted
public static void main(String[] args) {
//Alphabet
List<String> list = Arrays.asList("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");
//Sysout from the head for the time being
list.forEach(System.out::println);
//Sysout with multithreading
list.parallelStream().forEach(System.out::println);
//sort(Character code order)And Sysout
list.stream().sorted().forEach(System.out::println);
//sort(In alphabetical order(If the alphabet is the same, lowercase → uppercase))And Sysout
list.stream().sorted(String::compareToIgnoreCase).forEach(System.out::println);
}
Recommended Posts