Top "Java-stream" questions

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

Java8: HashMap<X, Y> to HashMap<X, Z> using Stream / Map-Reduce / Collector

I know how to "transform" a simple Java List from Y -> Z, i.e.: List<String> …

java mapreduce java-8 java-stream collectors
Should I always use a parallel stream when possible?

With Java 8 and lambdas it's easy to iterate over collections as streams, and just as easy to use a parallel …

java parallel-processing java-8 java-stream
How can I get a List from some class properties with Java 8 Stream?

I have a List<Person>. I need to get a List from a property of Person. For example, …

java collections java-8 java-stream
Java 8: How do I work with exception throwing methods in streams?

Suppose I have a class and a method class A { void foo() throws Exception() { ... } } Now I would like to call …

java java-8 unhandled-exception java-stream
Java 8 - Best way to transform a list: map or foreach?

I have a list myListToParse where I want to filter the elements and apply a method on each element, and …

java java-8 java-stream
Using Java 8's Optional with Stream::flatMap

The new Java 8 stream framework and friends make for some very concise java code, but I have come across a …

java lambda java-8 java-stream
Java 8, Streams to find the duplicate elements

I am trying to list out duplicate elements in the integer list say for eg, List<Integer> numbers = …

java lambda java-8 java-stream
Java 8 stream's .min() and .max(): why does this compile?

Note: this question originates from a dead link which was a previous SO question, but here goes... See this code (…

java java-8 java-stream
Java 8 lambda get and remove element from list

Given a list of elements, I want to get the element with a given property and remove it from the …

java lambda java-8 java-stream
Ignore duplicates when producing map using streams

Map<String, String> phoneBook = people.stream() .collect(toMap(Person::getName, Person::getAddress)); I get java.lang.IllegalStateException: Duplicate …

java java-8 java-stream