I have two references, reference a point to object a, reference b point to object b, then I called a swap function to try to let a point to object b, b point to object a, it is swapped in the swap function, but result in main function didn't change. So what I should do?
The swap function:
private void swap(Stack<TreeNode> a, Stack<TreeNode> b) {
Stack<TreeNode> temp = new Stack<TreeNode>();
temp = a;
a = b;
b = temp;
}