Java does not copy objects unless you explicitly ask it to. It is not C++. When you assign an object variable, what you're really doing is copying a reference.
When you rotate a node, you need to update the parent node to point to its new child. The only exception is when you're rotating the root node, which has no parent node.
AVLNode temp = a.root.right;
temp = rotateR(temp);
AVLNode temp = a.root.right;
a.root.right = rotateR(temp);
These two snippets of code do NOT do the same thing. In the first example, you're just reassigning the local variable temp
. In the second, you're updating the rotated node's parent to point to its new child.