How come the following prints boss and not bass?
String boss = "boss";
char[] array = boss.toCharArray();
for(char c : array)
{
if (c== 'o')
c = 'a';
}
System.out.println(new String(array)); //How come this does NOT print out bass?It prints boss.
c's value is a copy of the value in array. Access array directly to change the value in question.