Question
The below code show that when affecting an array to an another one, the two arrays becomes depending to each others.
int tab [] = {1,2,3}; int tab2 [] = tab; tab2[0] = 5; System.out.print(tab[0]); // 5 I want to know why this isn't the same with the type String, since if we had the following :
String ch1 = "hello"; String ch2 = ch1; ch2 = "hi"; System.out.print(ch1); // hello The two variables ch1 and ch2 are referencing the same string, so changing one will affect the other.
ch2.