package .;
import ;
import ;
import ;
import ;
import ;
import ;
public class ScreeningAndSlicing {
/**
* 映射
*/
@Test
public void test2(){
List<String> list = ("aa", "ss", "dd");
().map(str->()).forEach(::println);
Employee1 employee1=new Employee1("11");
Employee1 employee2=new Employee1("222");
Employee1 employee3=new Employee1("333");
List<Employee1>list1=new ArrayList<>();
(employee1);
(employee2);
(employee3);
new EmployeeData(list1);
("======================");
List<Employee1> employee1s = EmployeeData.getEmployee1s();
// ().map(e->().length()>3).forEach(::println);
Stream<String> stringStream = ().map(Employee1::getName);
(s->()>=3).forEach(::println);
//flatMap--接受一个函数作为参数,将流中的每个值都换成另一个流,然后把所有流连接成一个流
Stream<Stream<Character>> streamStream = ().map(ScreeningAndSlicing::fromStringToStream);
(s->{
(::println);
});
("使用flatMap进行简化");
//使用flatMap进行简化
Stream<Character> characterStream = ().flatMap(ScreeningAndSlicing::fromStringToStream);
(::println);
}
public static Stream<Character> fromStringToStream(String str){
ArrayList<Character> list=new ArrayList<>();
for(Character c:()){
(c);
}
return ();
}
/**
* 排序
*/
@Test
public void test(){
List<Integer>list=(1,24,1,23,1,243,1,41,-1,123,12,3);
().sorted().forEach(::println);
//定制排序
List<Employee1> employee1s = EmployeeData.getEmployee1s();
().sorted((e1,e2)->{
return ().compareTo(());
}).forEach(::println);
}
}