Java lambda sublist
•
Java
What is the shortest path to express "conditions for obtaining new list B from list a" through Java 8 lambda?
Say I have list < integer > A = arrays Aslist (1,2,3,4,5), I want a new list, B, whose value is > 3
I've read the new collections streams API, but I don't believe I've found the best way to do this, and I don't want to blame the problem on a solution that may not be perfect for me
Solution
a.stream().filter(x -> x > 3).collect(Collectors.toList());
a.stream().filter(x -> x > 3).collect(Collectors.toList());
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码