Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Deep copy cloning

807607Oct 31 2006 — edited Nov 1 2006
hi guys, i have an object which extends defaultmutabletreenode, basically it is a leaf on a tree and these leafes (not leaves then i guess but you know what i mean) have leaves themselves, as shown below, every node has an arraylist and these nodes also contain arraylists. i want to clone this object to see if it is quicker than re-creating it all of the time but i am a little hesitent as i am worried about getting a deep clone to work and unfortunately i couldnt find one that someone has already written.
am i right in thinking that you cant simply clone mychildren, you then have to go to every chidl and clone its children also??
below is the top of the class so you cans ee what it looks like...could anyone post a loop that would clone the tree or if it is a lot of trouble just a description of what i need to do would be great!


public class Node extends DefaultMutableTreeNode
{

private RootNode myRootNode;
private ArrayList<Node> myChildren;

thanks in advance to all who reply
Danny =)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 29 2006
Added on Oct 31 2006
7 comments
139 views