dcsimg
About Tree structure.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mohammad_Ali
Posted On:   Friday, June 8, 2001 10:37 PM

how can i use tree structure in java.Is there any built-in class that i can use.

Re: About Tree structure.

Posted By:   Sandip_Chitale  
Posted On:   Monday, June 11, 2001 09:18 PM

Maybe


  • javax.swing.tree.TreeModel

  • javax.swing.tree.TeeNode


and related subclasses and implementations.

Re: About Tree structure.

Posted By:   Luigi_Viggiano  
Posted On:   Saturday, June 9, 2001 05:24 AM

No, there's no structures to represent a Tree. You can use collections.

A collection can contain more objects (leafs), and each leaf can be again a collection (node) and contain more leafs and so on...


Collection
|
|--Object
|--Object
|--Collection
| |--Object
| |--Collection
| | |--Object
| | |--Collection
| | |-Object
| | |-Object
| | |-Object
| |--Object
|--Object

As collection I suggest you to use an ArrayList or LinkedList (or TreeList if you want leafs ordered).

If leafs are unique inside a node, I suggest you to use instead an HashSet (or TreeSet if you want leafs ordered).
About | Sitemap | Contact