Editing a tile map while running

My problem is this, i have a platformer game that uses a String for the tile map, such as this

 String map[] = {
		"11111111111111111111111111111111111111111111111111111111111111111111111",
		"10000000000000000000000220000000000000000000000000000000000000000000001",
		"10000000000000000000220000000000000000000000000000000000000000000000001",
		"10000000000000002200000000000000000000000000001110000000000000000000001",
		"1000000000E022000000000000000000000000000001111110000000022222200000001",
		"10000000022000000000000000000000000000011111111111000000000000000000001",
		"10000000000000000000000000000000000011111111111111111111111000011111111",
		"11111111111111111111111111111111111111111111111111111111111111111111111"
		
	};

Now the problem is that sometimes i need to edit the map while the game is playing, such as changing an E to a 0 or something to the affect, but everytime i want to go and change an individual character in the map i get an “unexpected type” error. This is how i try to do it

for (int i = 0; i<map.length; i++) {
			for (int j = 0; j < map[0].length(); j++) {
				char c = map[i].charAt(j);
				if (c == 'E') {
					enemy[enemyIndex] = new Enemy(elite,eliteAttack,i*tileW,j*tileH,this, 3);
					enemyIndex++;
					map[i].charAt(j) = "0";
				}
			}
}

Right on the line where i try to change the value of the character in the map, i get an “unexpected type” error pointing to the oppening round bracket. I know im probably overthinking this and its easier than i think, but i really need help on how to do this. Thanks

  1. Strings are immutable.
  2. “0” is a String and not a char.
  3. String.charAt is a method, which returns the character at that position.
  4. You cannot assign some value to some method.

Simple solution: use a 2d array (byte, short, char or int) instead.

Or use StringBuffer-its basicaly mutable String-u can change individual chars…

Sure. But that’s awfully long winded and a waste of processing power, therefore I didn’t mention it.

map[i].charAt(j) = “0”;

That wont work. Try map[i][j] = “0” but I am not sure and cant test it right now.