Skip to content
Advertisement

How to Avoid nested for Loops in java to get the heirarchical data?

// This method will return the list of reference names, in this method I wrote the code using nested //for-loops this handle only 3 subfolders set what if there is one more subfolder and how to handle it //without for loops, OverAll I should handle it dynamically

JavaScript

//for-loops this handle only 3 subfolders set what if there is one more subfolder and how to handle it //without for loops, OverAll I should handle it dynamically

JavaScript

Advertisement

Answer

If you are using Java 8, streams with flatmap will help you to achieve this. Something like this https://dzone.com/articles/walking-recursive-data

If java 7 we can iterate the OrgSubfolderDetails recursively.

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