I do not understand how String arrays are affected by equal signs (variable and element assignment)
19:44 02 Jan 2019
import java.util.ArrayList;
public class MyClass {
    public static void main(String args[]) {
     String[] xy = {"X", "Y"};
     String[] yx = xy;
     yx[0]=xy[1];
     yx[1]=xy[0];
     System.out.println(xy[0] + xy[1]+yx[0]+yx[1]);
    }
}

When I run this through Eclipse and other programs it always prints YYYY instead of XYYX. How is this happening?

When I began experimenting with the code, I ended up with XXXX when I removed yx[0]=xy[1]. I think it possibly has something to do with the equal signs but I am confused by how it outputs YYYY rather than XYYX.

java arrays string reference variable-assignment