screening list element contains a specific string, then inversion element, the weight again (using jdk8 stream)

Can be used to re-set, as used herein, jdk8 stream to weight.

E.g:

 1     public static void main(String[] args) {
 2         String subStr = "a";
 3         List<String> list = new ArrayList<>(Arrays.asList("abc", "test", "ivy", "absent", "total", "jack", "woo", "java", "Jenkins", "docker","test","Docker"));
 4         List<String> tempList = new ArrayList<>();
 5         //筛选包含a的元素
 6         for (String s :list) {
 7             if (!s.the contains (substr)) {
new new                 String = Reverse. 9element inversion//. 8                 
 StringBuffer(s).reverse().toString();
10                 tempList.add(reverse);
11             }
12         }
13 
14         //去重
15         List<String> result = tempList.stream().distinct().collect(Collectors.toList());
16         System.out.println(result.get(0));
17         System.out.println(result.get(1));
18         System.out.println(result.get(2));
19 
20     }

 

Guess you like

Origin www.cnblogs.com/ivy-xu/p/12519605.html