Possible Duplicate:
Java tree data-structure?
I want to represent a hierarchical structure in java. The hierarchy can be of the form
Key
|
|-Value1
| |-Value11
| |-Value111
|-Value2
| |-Value22
|-Value3
|-Value4
Can anyone suggest me the best possible data structure to represent this kind of hierarchy in java?
See this answer:
Java tree data-structure?
Basically, there is nothing in the standard libs that offers a Tree representation out of the box, except for the JTree in the swing package.
You can either roll your own (some tips offered in the linked answer), or use that one, which works well actually.
Basically what you need is just an structure that will hold a few children and you model properties. You could represent this with a class structure like this:
You could take a look here, in order to take some ideas: Java tree data-structure?