After I replace the index 0 of an array in the function, the value of arrayCharacter
is also changed. The result is
[A, B, C] [ko, B, C] [ko, B, C]
I don't understand why the result is not:
[A, B, C] [A, B, C] [A, B, C]
This is my code:
public static void main(String[] args) {
String[] arrayCharacter = new String[]{"A", "B", "C"};
for (int i = 0; i < 3; i++) {
proses(arrayCharacter);
}
}
public static void proses(String[] arrayCharacter) {
String[] characterTemp = arrayCharacter;
System.out.println(Arrays.toString(arrayCharacter));
characterTemp[0] = "ko";
}
}