Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Beware Of findFirst() And findAny()

After filtering a Java 8 Stream it is common to use findFirst() or findAny() to get the element that survived the filter. But that might not do what you really meant and subtle bugs can ensue. So What’s Wrong With findFirst() And findAny()? As we can see from their Javadoc (here and here) both methods ...



This post first appeared on Java Code Geeks, please read the originial post: here

Share the post

Beware Of findFirst() And findAny()

×

Subscribe to Java Code Geeks

Get updates delivered right to your inbox!

Thank you for your subscription

×