Skip to content
Kango edited this page Apr 9, 2017 · 10 revisions

Replace a Char in a String At a position

void draw () { 

 println(ReplaceCharAt("Buljdog",'l',3));

}

String ReplaceCharAt(String Word, char ReplacingLetter, int AtPos ) {        

   StringBuffer StringBufferName = new StringBuffer(Word); // Word in which we replace        

   StringBufferName.setCharAt( AtPos, ReplacingLetter );    

   return (StringBufferName.toString());

} // func

could also be called via:

println("before " + buffer[bufferWritePosition][depth] ) ;

buffer[bufferWritePosition][depth] = ReplaceCharAt ( buffer[bufferWritePosition][depth], '*', i );

println("after " + buffer[bufferWritePosition][depth] ) ;      

Problem
No check if String is too short

by
TfGuy44 and koogy

Clone this wiki locally