How to implement a tree data-structure in Java?

Is there any standard Java library class to represent a tree in Java?

Specifically I need to represent the following:

  • The sub-tree at any node can have an arbitrary number of children
  • Each node (after the root) and it’s children will have string value
  • I need to get all the children (some sort of list or array of Strings) of a given node and it’s string value(i.e. a method that will take a node as input and return all the string values of the children node as output)

Is there any available structure for this or do I need to create my own (if so implementation suggestions would be great).

Leave a Comment