Bootstrap

Java:steam,中间方法:skip,dinctinct,concat,

public class shuangliejihe {
   public static void main(String[] args) {

       ArrayList<String> list = new ArrayList<>();
       Collections.addAll(list,"张无忌","周芷若","赵明","张强","张三丰","张翠山") ;
       list.stream().filter(new Predicate<String>() {
           @Override
           public boolean test(String s) {
               return   s.startsWith("张");
           }
       });

    list.stream()
            .filter(s->s.startsWith("张"))
            .filter(s->s.length()==3)
            .forEach(s->{System.out.println(s);});
//stream流获取的数据只能使用一次,所以常用链式编程
//修改stream流中的数据不会影响原来的数据

//要四个
       //list.stream().limit(4).forEach(System.out::println);
       //跳过前三个,总共获取三个
       list.stream().skip(3).limit(3).forEach(System.out::println);

       //去重
       list.stream().distinct().forEach(System.out::println);
       
       //合并A和b两个流为一个流
       List<String> list2 = new ArrayList<>();
       Collections.addAll(list2,"张若栏","周杰界");
       Stream.concat(list.stream(),list2.stream()).distinct().forEach(System.out::println);
   }
}