相关疑难解决方法(0)

什么是Java 8 Stream API中的收集器的默认Set/List实现?

我在Java 8下面有代码快照.

 List<Employee> employees = DataProvider.getEmployees();
 Set<Employee> set = employees.stream().filter(emp -> {
                System.out.println(emp.getName());
                return emp.getName().equals("Vishal");
            }).collect(Collectors.toSet());
Run Code Online (Sandbox Code Playgroud)

我只是想知道Set它在使用时使用默认的哪个实现Collectors.toSet()(参见上面的例子)?

另外,有没有办法表明java API使用特定的实现(例如HashSet)?

java-8 java-stream collectors

2
推荐指数
1
解决办法
665
查看次数

标签 统计

collectors ×1

java-8 ×1

java-stream ×1