Skip to content
Advertisement

How to Iterate list of list of Java Objects using Java 8

How to iterate and get through list of list of objects using Java 8 Also need to get the count of distinct customerIds

JavaScript

CustomerEditVO and CustomerIssues are POJOs

Post Request body —>

JavaScript

Advertisement

Answer

I have created all the given POJO’s and created the objects and list for your query.And also overrides the toString() method in order to clearly show the objects in the list output and also extracted and print the list at each operation.

NOTE:: 1) Need to override hashcode and equals method to find the distinct() list and count based on customerId. 2) You can use flatMap to convert listOfList of objects in a single list of objects

JavaScript
JavaScript
JavaScript

Output

JavaScript

I hope this will solve your problem.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement