Generic tree implementation in Java

后端 未结 10 1300
甜味超标
甜味超标 2020-12-28 12:29

Is anyone aware of a generic tree (nodes may have multiple children) implementation for Java? It should come from a well trusted source and must be fully tested.

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-28 13:16

    There isn't a Tree class in the Collections libraries. However, there is one in the Swing Frameworks. DefaultTreeModel

    I have used this in the past and it works well. It does pull in additional classes into your application though which may or may not be desirable.

    You can also simulate a Tree using another collection and storing collections in it. Eg. List of Lists.

提交回复
热议问题