Is there a good data structure that is tree in Java? All I need is
Can I make something like this?
java date-structures tree
public class Tree<T> {
private Node<T> root;
public Tree(T rootData) {
root = new Node<T>();
root.data = rootData;
root.children = new ArrayList<Node<T>>();
}
public static class Node<T> {
private T data;
private Node<T> parent;
private List<Node<T>> children;
}
}
This is a basic tree structure that can be used as a String or other object. You can easily modify it in any other form you want. You just need to add things like insert, delete, and modify. Node is the default unit of the tree.
© 2024 OneMinuteCode. All rights reserved.