Top "Java-stream" questions

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

Remove first element of a Stream in Java 8

I have generated a Stream in Java 8 with Files.walk() method from java.nio library. The problem is that the …

java filter functional-programming java-stream java.nio.file
Java 8 Stream "collect and group by" objects that map to multiple keys

I have the following objects: public class Item { String value; List<Person> owners; Person creator; } public class Person { …

java-8 java-stream collectors
Java 8 functional interface with no arguments and no return value

What is the Java 8 functional interface for a method that takes nothing and returns nothing? I.e., the equivalent to …

java java-8 java-stream
How do I get an IntStream from a List<Integer>?

I can think of two ways: public static IntStream foo(List<Integer> list) { return list.stream().mapToInt(Integer::…

java collections java-8 java-stream boxing
How to handle Exception in Java 8 Stream?

I have a method where I am traversing through a List and creating List. While doing so, I am calling …

java exception java-8 java-stream throws
Creating Map composed of 2 Lists using stream().collect in Java

As for example, there are two lists: List<Double> list1 = Arrays.asList(1.0, 2.0); List<String> list2 = Arrays.…

java-8 java-stream collectors
How can I make Cartesian product with Java 8 streams?

I have the following collection type: Map<String, Collection<String>> map; I would like to create …

java java-8 java-stream cartesian-product
Java 8 streams group by 3 fields and aggregate by sum and count produce single line output

I know there a similar questions asked in the forum but none of them seem to be addressing my problem …

lambda java-8 java-stream chaining collectors
Stream groupingBy: reducing to first element of list

I have a List<Valuta> which can be represented (simplified) JSON-style: [ { codice=EUR, description=Euro, ratio=1 }, { codice=USD, …

java java-8 grouping java-stream collectors
How to use stream in Java 8 to collect a couple of fields into one list?

For example I have class Person with name and surname fields. I want to collect a List of String (names …

java java-8 java-stream collectors