1    重点

1.1  max,min,count 方法 最大/最小/计数

 

2    Demo之Max

demo:

   @Test
    public void maxTest(){
        OptionalDouble optional = list.stream().mapToDouble(sku->sku.getTotalPrice()).max();
        System.out.println(optional.getAsDouble());
    }

 

 

打印日志:

5000.0

Process finished with exit code 0

 

3    Demo之Min:

demo:

   @Test
    public void minTest(){
        OptionalDouble optional = list.stream().mapToDouble(sku->sku.getTotalPrice()).min();
        System.out.println(optional.getAsDouble());
    }

 

 

打印日志:

20.0

Process finished with exit code 0

 

 

 

 

4    Demo之count:

 demo:

 @Test
    public void countTest(){
        long lNumber = list.stream().count();
        System.out.println(lNumber);
    }

 

 

 

 

打印日志:

8

Process finished with exit code 0

 

posted on 2020-04-30 06:06  菜鸟乙  阅读(161)  评论(0编辑  收藏  举报