1、Java8 -List.sort Java8 List sortList words = Arrays.asList(B,C,A);words.sort(new Comparator() public int compare(String o1, String o2) return pareTo(o2););words.sort(o1,o2)-pareTo(o2); /Lambdawords.sort(String:compareTo);/words.sort(Comparator.reverseOrder(); /words.sort(Comparator.nullsFirst(Compar
2、ator.reverseOrder();/nullJava8 -forEach Java8 Iterable forEach()Iterablewords List Setwords.forEach(e-System.out.println(e);words.forEach(System.out:println);Java8 Stream Lambda Java8 StreamforEachList list = new ArrayList();for (int i = 0; i e5).forEach(System.out:println);Java8 Stream Lambda5 List
3、List list = integerList.stream().filter(e-e5).collect(Collectors.toList();1. stream()2. filter3. collect4. (collect) Collectors.toList() ListList integerList = new ArrayList();for (int i = 0; i 5; i+) integerList.add(i);for (int i = 0; i integerList.size(); i+) if(integerList.get(i) 5)integerList.remove(i);integerList.forEach(System.out:println);IteratorDelete.java Collection List Setadd remove containsclear equals AbstractList AbstractQueue ArrayList HashSet