lundi 5 avril 2021

How to register object to ArrayList during creation

I am dynamically creating tree with nodes of type A,B and C. Which node is created is chosen during execution. For example tree: !(https://ibb.co/F8qX9dW)

I also want to have ArrayList with all created nodes of type C. (In the end - tree is very huge, places where node C can be created is a lot, real number of node type C is not enough - so its not optimal for visiting whole tree every time I need work with this nodes)

My question is: Is possible in constructor of class C also save this object to mentioned arraylist?

Thanks

Aucun commentaire:

Enregistrer un commentaire