Java 8 集合类新增方法详解
在 Java 8 中,对集合中方法有变动的类有以下几个:
-
List 接口:新增了 sort() 和 replaceAll() 方法。
-
Map 接口:新增了 forEach()、replace()、replaceAll()、compute()、merge() 等方法。
-
Set 接口:新增了 forEach()、removeIf() 等方法。
-
Collection 接口:新增了 stream()、parallelStream()、forEach()、removeIf() 等方法。
-
Arrays 类:新增了 parallelSort()、setAll()、parallelSetAll() 等方法。
-
Comparator 接口:新增了 comparing()、thenComparing()、reversed() 等方法。
-
Iterator 接口:新增了 forEachRemaining() 方法。
-
Stream 接口:新增了 filter()、map()、flatMap()、reduce()、collect() 等方法。
-
ConcurrentHashMap 类:新增了 forEach()、search()、reduce() 等方法。
-
Optional 类:新增了 ifPresent()、orElse()、orElseGet()、orElseThrow() 等方法。
原文地址: https://www.cveoy.top/t/topic/jI1I 著作权归作者所有。请勿转载和采集!