Ok I suppose you are not allowed to use replaceAll()
as that would make this task trivial ;-)
Now what you want to do is take a look at the String javadoc and figure out how you could replace a character using the method substring(int beginIndex, int endIndex)
.
And then you think of a way how you can combine that in a for
loop with charAt(int index)
which gives you the character at the specified index.
Actually you could also take a look at split()
as that could be also used to replace a character:
String s = "halalo";
String [] split = s.split("a");
// split now contains: split[0] = "h", split[1] = "l", split[2] = "lo"