函数式编程(Streams)返回类型ArrayList java
我有一个列表和另一个ArrayList。我想区分它们并返回新的ArrayList函数式编程(Streams)返回类型ArrayList java,java,functional-programming,java-8,java-stream,Java,Functional Programming,Java 8,Java Stream,我有一个列表和另一个ArrayList。我想区分它们并返回新的ArrayList String[] input = scn.nextLine().split("\\s"); ArrayList<String> result = Arrays.stream(input).filter(a -> a.length() > 10).distinct() String[]input=scn.nextLine().split(\\s”); ArrayList结果=Arrays.s
String[] input = scn.nextLine().split("\\s");
ArrayList<String> result = Arrays.stream(input).filter(a -> a.length() > 10).distinct()
String[]input=scn.nextLine().split(\\s”);
ArrayList结果=Arrays.stream(input).filter(a->a.length()>10).distinct()
我想返回ArrayList。我在返回列表(Collectors.asList等)方面没有问题
将收集为列表,然后从所述列表创建新的ArrayList。收集为列表,然后从所述列表创建新的ArrayList。收集为列表,然后从所述列表创建新的ArrayList。收集为列表,然后从所述列表创建新的ArrayList。您应该通过
收集
方法:
ArrayList<String> result = Arrays.stream(input)
.filter(a -> a.length() > 10)
.distinct()
.collect(Collectors.toCollection(ArrayList::new));
您应该通过
collect
方法收集结果:
ArrayList<String> result = Arrays.stream(input)
.filter(a -> a.length() > 10)
.distinct()
.collect(Collectors.toCollection(ArrayList::new));
您应该通过
collect
方法收集结果:
ArrayList<String> result = Arrays.stream(input)
.filter(a -> a.length() > 10)
.distinct()
.collect(Collectors.toCollection(ArrayList::new));
您应该通过
collect
方法收集结果:
ArrayList<String> result = Arrays.stream(input)
.filter(a -> a.length() > 10)
.distinct()
.collect(Collectors.toCollection(ArrayList::new));
谢谢你的回答!对不起,重复了!谢谢你的回答!对不起,重复了!谢谢你的回答!对不起,重复了!谢谢你的回答!对不起,重复了!