Basic element for object, shallow copy, copy reference (ArrayList clone () call arrays.copyof (), official document marked as shallow copy)
classa{intA; PublicAinta) { This. a=A; } PublicString toString () {returnA + ""; }} a[] KK=NewA[2]; kk[0]=NewA (1); kk[1]=NewA (2); A[] KKK=arrays.copyof (kk,2); System.out.println (KK==KKK); System.out.println (Kk.equals (KKK)); System.out.println (Arrays.tostring (KK)); System.out.println (arrays.tostring (KKK)); kk[0].a=555555; System.out.println (Arrays.tostring (KK)); System.out.println (arrays.tostring (KKK));
/*
False
False
[1, 2]
[1, 2]
[555555, 2]
[555555, 2]
is a value,
int [] a=newint[2]; a[0]=11; a[1]=2; int [] B=arrays.copyof (A, 2); a[1]=3333333; System.out.println (Arrays.tostring (a)); System.out.println (arrays.tostring (b)); /* output[11, 3333333][11, 2]
About the Java Copy array method arrays.copyof () is address passing or value passing