I have a stream from elements of a class x. One of the arributes (t) of the class x is from type LocalDateTime and I need to group the elements by hou ...
I have a stream from elements of a class x. One of the arributes (t) of the class x is from type LocalDateTime and I need to group the elements by hou ...
I did the code below to have a dropdown box with all the currencies code. List<String> currencies = Currency.getAvailableCurrencies().stream() ...
I have stream of objects. I want to group them and calculate the division of sum of values I get from object functions. import java.util.Map; import ...
I have the following List<String>, resultList that I want to convert to a Map<Long, List<String>> The Map should look like the fo ...
Seems like a very basic question, I want to convert my 2d string array into a Map with List as a Value. I've tried something like below: My nested ...
I have a custom type which looks like this: The ValueObject just contains some Strings. And I have a List of SampleObjects payload. Within that li ...
For loop code is this. Param : ArrayList userList and i want to modify stream my stream code grouping list succefully but i want to remove same ...
I have a input object and the output object is In the Txn object transfers the amount from the withdrawId -> depositId. what I am doing is I ...
I have a class Student: And I have a list of Student instances called students. I want to create a new list which will contain the Students groupe ...
Assume I have the following domain object: There is a list List<MyObj> list. I want to create a Map by grouping the data by relationId (*key) ...
I have the following domain classes: And I have a list of tasks called tasks. I would like to group Task objects by project's ids. The resulting ...
How can the following method be written using Java Stream API? I tried something like this: But I don't know how to continue from here. ...
I'm using Collectors.groupingBy to group may objects into list. Examples are as follows: Output: But my goal is to sort StudentDTO by score usin ...
How to create Map<String,List<Product>> of below. Here, String (key of the Map) is the category of a Product. One product can belong to m ...
I have been trying to write a method called printableStringCollector, which basically returns a collector that forms a special printable String as des ...
The following code works but it does take into account upper or lower case, and the result is a non alphabetically ordered list: Then I came across ...
I have the following Item class: And there's a List of items like shown below: I need to group Item by Type and store into a map. And then I ne ...
I have an Item class which contains a code, quantity and amount fields, and a list of items which may contain many items (with same code). I want to g ...
I have Employee defined as follows: There's a list of Employee. I am trying to get an employee with the second-highest salary for each department. ...
I have the following Student object: In the original code, properties and are enums, but for the purpose of simplicity let's consider them to be ...