Top "Java-stream" questions

Use this tag for questions related to the use of the Stream API.

Java 8 reference to a static method vs. instance method

say I have the following code public class A { int x; public boolean is() {return x%2==0;} public static boolean is (…

java java-8 java-stream method-reference
Java stream merge or reduce duplicate objects

I need to generate a unique friend list from a list that can have duplicates by merging all duplicate entries …

java list merge java-stream reduce
How to create Flux from Mono

I have a Mono A. The Object A contains two lists. I want to create direct two Flux. Is this …

java java-stream spring-webflux
Java 8 stream join and return multiple values

I'm porting a piece of code from .NET to Java and stumbled upon a scenario where I want to use …

java dictionary java-8 java-stream collect
arg max in Java 8 streams?

I often need the maximum element of a collection according to the maximization of a criterion which produces a double …

java java-8 java-stream argmax
When should streams be preferred over traditional loops for best performance? Do streams take advantage of branch-prediction?

I just read about Branch-Prediction and wanted to try how this works with Java 8 Streams. However the performance with Streams …

java performance java-8 java-stream branch-prediction
In Stream reduce method, must the identity always be 0 for sum and 1 for multiplication?

I proceed with java 8 learning. I have found an interesting behavior: let's see code sample: // identity value and accumulator and …

java java-8 java-stream reduce
Java collect with lambda expression example

I was trying to convert this String r = ""; for ( Persona p : list ) { r += p.lastName; } To stream().filter.collect() form, …

java lambda java-stream collect
Java 8 - How to use predicate that has a function with parameter?

I have the following code: public boolean isImageSrcExists(String imageSrc) { int resultsNum = 0; List<WebElement> blogImagesList = driver.findElements(blogImageLocator); …

java lambda java-8 java-stream predicate
Idiomatically creating a multi-value Map from a Stream in Java 8

Is there any way to elegantly initialize and populate a multi-value Map<K,Collection<V>> using …

java dictionary java-stream multimap