Last active
November 1, 2018 02:23
-
-
Save zhuifeng1017/3a8161086959b31598c66a1d5995c308 to your computer and use it in GitHub Desktop.
Java8 stream filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//filter eg | |
String strs[] = new String[]{"1","2", "0", "33", "3", "4","abc"}; | |
List list = Arrays.stream(strs).filter(b -> b.length()<3 ).sorted().collect(Collectors.toList()); | |
list.stream().forEach( System.out::println); | |
System.out.println("------------------"); | |
// map eg | |
List list2 = Arrays.stream(strs).map(v->v.substring(0,1)).sorted().collect(Collectors.toList()); | |
list2.stream().forEach( System.out::println); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment