public String replace(char oldChar,char newChar){
  int index=indexOf(oldChar,0);
  if (index == -1) {
    return this;
  }
  char[] buffer=new char[count];
  System.arraycopy(value,offset,buffer,0,count);
  do {
    buffer[index++]=newChar;
  }
 while ((index=indexOf(oldChar,index)) != -1);
  return new String(0,count,buffer);
}

public String replace ( char oldChar , char newChar ) { int index = indexOf ( oldChar , 0 ) ; if ( index == - 1 ) { return this ; } char [ ] buffer = new char [ count ] ; System . arraycopy ( value , offset , buffer , 0 , count ) ; do { buffer [ index ++ ] = newChar ; } while ( ( index = indexOf ( oldChar , index ) ) != - 1 ) ; return new String ( 0 , count , buffer ) ; }
copies this string replacing occurrences of the specified character with another character .
