public class Test { public static void main(String[] args) { int[] a = {1, 2, 3, 4, 5}; int[] b = a; int[] c = {6, 7, 8}; a = c;
This is why:
What is Object Reference Variable?
You have 2 objects (the arrays) and 3 references (a, b, c) to the objects. You're just swapping around where things are pointed.