1,作用:

简化集合和数组的操作;在Stream流里面对数据处理;

2,Stream流的操作步骤:

  1. 获取Stream流
  2. 中间方法;
  3. 总结方法;

    3,集合的操作方法:

    a,集合的Stream流获取:(注意 : map集合不能直接获取,要先获取键再获取流)

    image.png

    b,使用范例:

    ```java //list集合: ArrayList list =new ArrayList<>(); Stream stream = list1.stream();

//map集合:先获取键: HashMap map = new HashMap<>(); //方式1: Stream stream2 = map.keySet().stream(); //方式2: Stream> stream3 = map.entrySet().stream();

  1. <a name="YFq6S"></a>
  2. ## 4,数组的操作方法:
  3. <a name="G2tIq"></a>
  4. ### a,数组的Stream流获取:
  5. ![image.png](https://cdn.nlark.com/yuque/0/2022/png/25975946/1645171186978-06d89a7b-6105-4ce5-8aa7-3ab618740fbe.png#clientId=u59222616-007b-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=96&id=u77fa239c&margin=%5Bobject%20Object%5D&name=image.png&originHeight=96&originWidth=944&originalType=binary&ratio=1&rotation=0&showTitle=false&size=13402&status=done&style=none&taskId=u8991bbc3-252a-4b09-b5dc-02f4658b66d&title=&width=944)
  6. <a name="CO1au"></a>
  7. ### b,使用范例:
  8. ```java
  9. //数组:
  10. String[] array={"da","daf","da"};
  11. Stream.of(array);
  12. //字符串,可变数据:
  13. Stream<String> stream4 = Stream.of("da", "da");