package com.study.Day7;
import java.lang.reflect.Array;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Demo013 {
public static void main(String[] args) {
List<String> list= Arrays.asList("周润发","成龙","刘德华","吴京","周星驰","李连杰");
List<String>list1=Arrays.asList("林心如","张曼玉","林青霞","刘岩","林志玲","王祖贤");
Stream.concat(list.stream().filter(s->s.length()==3).limit(3),list1.stream().filter(o->o.startsWith("林")).skip(1))
.map(Actor::new).forEach(c1-> System.out.println(c1.getName()));
list=list.stream().filter(c->c.startsWith("周")).collect(Collectors.toList());
System.out.println(list);
Set<String> set1= Set.of("周润发,1","成龙,2","刘德华,3","吴京,4","周星驰,5","李连杰,6");
/*set1=set1.stream().filter(a->a.length()==2).collect(Collectors.toSet());
System.out.println(set1);*/
Map<String,Integer>map=set1.stream().collect(Collectors.toMap(c->c.split(",")[0],c->Integer.parseInt(c.split(",")[1])));
Set<Map.Entry<String,Integer>>se=map.entrySet();
for(Map.Entry<String,Integer> m:se){
System.out.println(m);
}
}
}
|
|