user3364192 user3364192 - 1 year ago 67
Java Question

Java 8 - ommiting tedious collect method

Java 8 stream api is very nice feature and I absolutely like it. One thing that get's on my nerves is that 90% of the time I want to have input as a collection and output as collections. The consequence is I have to call

method all the time:>p.isCorrect()).collect(Collectors.toList());

Is there any java api that would let me skip the stream and directly operate on collections (like
in c#?):


Answer Source

If you want to operate on collections Guava's FluentIterable is a way to go!

Example (get id's of 10 first vip customers):

       .filter(customer -> customer.isVIP())
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download