I would like to represent a (or many) Tree that may have more than one top node and children beneath them. All content is of String datatype and the end application is a Swing application where users should be shown the hierarchy of a selected top node in a tree structure.
E.g. data would be like
Root 1 Root 2
Child1 Child2 Child3 Child4
GrandChild 21 GrandChild 31 GrandChild 41
GrandChild 22 GrandChild 32
so if user clicks a Root 2... then i should be able to show him Root2's hierarchy... i.e. Root 2 has Child 3 & Child 4... & Child 3 has GrandChild31... so on
Currently I have thought to use the all the Roots as a separate list and a single hashmap for parent child mapping. So if a particular root is asked i will traverse the hashmap and print all its children. Is the Collection structure I use good?
<edit>Sorry that the alignment of Root and Child in the quote is not spaced up properly like i gave. Root2 has Child3 and Child4 in it..</edit>