3- Stream流-List

Stream编程

可简化代码,优化性能

  • demo1

集合元素进行过滤 以J开头的元素且长度为4,存储到新的元素中,然后输出

mark

结果

res = [Jack, JMas]
Process finished with exit code 0

Stream写法

mark

结果

collect = [Jack, JMas]
Process finished with exit code 0
posted @ 2019-08-12 20:32  Xieth  阅读(113)  评论(0编辑  收藏  举报