List<Dish> dishes = menu.stream()                         
                        .filter(d -> d.getCalories() > 300)                                     
                        .limit(3)                         
                        .collect(toList());

 

截断流limit

图片来源于java8 in action

相关文章:

  • 2021-11-13
  • 2022-12-23
  • 2021-11-27
  • 2021-06-03
  • 2021-11-01
  • 2021-11-17
  • 2021-07-31
  • 2021-11-19
猜你喜欢
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-06
相关资源
相似解决方案