Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
74 views

How to use groupby collectors while modifying the values

I'm preparing for a test and in preparation I was looking at this question, which I want to rewrite in the stream / collector way. The assignment is a wooden plank with nails hammered in. The nails ...
dr jerry's user avatar
  • 10.1k
0 votes
1 answer
43 views

Iterating a list once instead of twice

I have a json for students with marks . I need to get the total marks for maths and english per standard . I could do it for each subject like below , but here the list is iterated twice. Is there a ...
astar's user avatar
  • 327
2 votes
1 answer
70 views

Java Stream API: Incompatible types: List<ArrayList>> cannot be converted to List<List>

My intention was to replace the following snippet: List<List<String>> lists; for (int i = 0; i < n; i++) lists.add(new ArrayList<String>()); with Stream API one-liner: List&...
Alex G's user avatar
  • 41
0 votes
1 answer
34 views

Grouping By Child Class into Map

I had made a list of Parent Class (as Employee) having a parameter of child class (as Department) class Employee { Integer empId; String empName; Long salary; String email; ...
Ankit's user avatar
  • 2,256
0 votes
1 answer
119 views

Compiling Stream Gatherers / jdk24 features

I don't know how to fix this error: (I use IntelliJ IDEA 2024.2.5 (Community Edition) java: invalid source release 23 with --enable-preview (preview language features are only supported for release ...
Kristina Perez's user avatar
3 votes
2 answers
159 views

Collectors#toMap: No NPEs on null values

What if I don't want Collectors#toMap to throw on null values? Java 8 public class CollectorsTest { @Test public void collectorsTest() { List<Map.Entry<String, Object>> ...
Sergey Zolotarev's user avatar
0 votes
0 answers
62 views

Is there elegant way to fork and join Java streams?

I have quite simple task: there is a List<Map> exposed from unsorted YAMLs and JSONs. I need to filter the list to find some particular data structures and extract some part of them -- four ...
stasdavydov's user avatar
1 vote
1 answer
61 views

Create a list of data carriers with java Streams

I want to convert a list of nested objects into a flat list using Java streams. For this reason, a list of companies is first drawn up with employees: // create Apple Employees List<...
Hakan Kiyar's user avatar
2 votes
1 answer
66 views

JwkSet gives Cannot resolve constructor 'JWKSet(List<RSAKey>)' - Stream.collect(Collectors.toList()) vs Stream.toList()

In our code, we use JWKset from the nimbus-jose-jwt library in a method that creates a map that we use for stuff. As you can see in the return, we use a stream that calls map on a list of RSAkey, and ...
Mattias Gradin's user avatar
1 vote
0 answers
50 views

Lazy de-serialization of a JSON array as a Stream<T> [duplicate]

Consider I have a large (potentially infinite) array of JSON objects: [ { "id": 41, "name": "foo" }, { "id": 42, &...
Bass's user avatar
  • 5,368
2 votes
3 answers
229 views

How to sort a list of object by two fields when the first field is a date but of string type and the second field is a plain string

I have an array of Object that I need sorted by two of the object's fields. Product.java private String productionDate; private String productionCountry; private String productDescription; Now I ...
craftdeer's user avatar
  • 1,067
0 votes
2 answers
95 views

Object attribute always evaluates to not-null in a java streams map() transformation even though it is null in some cases

So say, I have a class: public class Clazz { final String someAttribute; public String getSomeAttribute() { return someAttribute; } public void setSomeAttribute(String ...
Sandeep Barnabas's user avatar
-4 votes
1 answer
100 views

How can I inflate entry stream?

With given map, Map.of( "A", 5, "C", 13, "E", 2, "M", 5, "T", 45, "W", 2 ); How can I ...
Jin Kwon's user avatar
  • 22.1k
-1 votes
2 answers
98 views

ArrayList filled with parallel stream contains null values ​and leaves some out [closed]

I am trying to fill an Arraylist, as there are usually very large values ​​I have decided to parallelize it with ExecutorService and CompletableFuture and later with parallel stream, but in both cases,...
Bolskan's user avatar
  • 21
-7 votes
1 answer
68 views

Need to group by list of list in pojo in java and sort by year and month

We are getting list of AssetValue from database, After getting the list I need to group by id and sort by year and month. Based on the grouping I need to print on reports. Public Class AssestValue{ ...
Michael Prabhu's user avatar

15 30 50 per page
1
2 3 4 5
809