I have two variables, x and y, and I want to swap their values. (For example, if x has value 20 and y has value "princess", then after the swap I want x to have value "princess" and y to have value 20.)
Can you explain why the code x = y y = x doesn't work.
I know how to use the temp variable and x,y but I was confused as to why the above method doesn't work. I have no code except for
x=y
y=x
I just need someone to explain why the method above doesn't work.