I need to copy two objects (which are both stacks).
I want to copy a temporary object's content into a current object and then clear the temporary object's content.
For example, with a tree, it would be something like:
tree = tempTree;
tempTree.clear();
But, tree reference now points to temptree and if I clear temptree, it will clear also tree. I looked on other posts, they talked about implements clonable or doing a copy constructor and I am sure there is a better way of copying objects in Java.
My objects are by the way Stack objects.
How can I copy contents from object to another without having same object reference ?