This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I am getting a tree with some child nodes from db. I want to store them in a proper variable like Hashmap or linkedhashmap or sortedset. But it should be able to go up to n-level in hierarchy. I am confused how to achieve that.
Please suggest some efficient ways or some similar examples.
Why not use a structure that's fit for a tree representation - like an actual tree structure. You can use DefaultMutableTreeNode if you don't feel like program any yourself. Although it's part of Swing, it can be used independently.