_//流的创建 只有Collection和数组可创建 Stream类
//单列集合 可使用Collecion的stream()默认方法生成流
//双列集合 可把双列结合 变成set集合 在用stream()默认方法生成流
//数组 用Arrays的静态方法stream生成流
//Stream
//filter筛选方法 参数为Predicate类接口的对象 接口中只有一个抽象方法 可用匿名内部类快速实现这个接口 并重写test方法
//test方法返回true或false
//filter(Predicate predicate)方法的作用是用Predicate类参数对象 并调用他里面的test方法 把流内部使用test方法返回为true的元素筛选出来 放回原来的流中
//limit获取前几个元素 放入原来的流中
//skip 跳过前几个元素 把剩下的放入原来的流中
//concat Steam流中的静态方法 合并两个流 到一个新流
//distinct 去除流中的重复元素 依赖元素中的equals和hashcode方法
//sorted 将流中元素安照自然规则排列 依赖元素类继承Comparable接口
//sorted 将流中元素按照指定规则排列 参数为比较器
//终结方法 使用终结方法后 流不能再接着使用
//forEach(Consumer action) 对流中的每个元素进行操作
// 参数为Consumer接口的对象 Consumer接口中只有一个accept抽象方法 可以使用匿名内部类快速创建接口子类对象
//并重写accept方法 accept方法的作用是对流中每一个元素做具体操作
//count方法 返回流中的元素个数
//collect(Collector collector)方法 参数是Collector收集器接口
//Collectors工具类提供了获得各种收集器的静态方法
//Collectors的tolist方法 获得一个Collector接口类型的list收集器
//Collectors的toset方法 获得一个Collector接口类型的set收集器
//Collectors的tomap(Function keyMapper,Function valueMapper)方法 获得一个map收集器
//第一个Function是提供键 第二个Function是提供数据值
//tomap方法的参数是Function类的接口对象 可以快速创建接口的匿名内部类对象 该对象有两个泛型
// Function接口只有一个apply抽象方法 该方法的参数为第一个泛型 返回值为第二个泛型
// 该方法的作用是把第一个泛型转为第二个泛型 方法体是转换类型的具体过程
//
_
public static void main(String[] args) {Student st = new Student("张三", 12, Sex.GIRL);String name = st.getName();System.out.println(name);ArrayList<Student> list = new ArrayList<>();list.add(st);Stream<Student> stream = list.stream();Stream<Student> stream1 = list.stream();Collectors.toMap(new Function<String, String>() {@Overridepublic String apply(String s) {return s;}}, new Function<String, String>() {@Overridepublic String apply(String s) {return null;}});}
_
