MCPcopy Create free account
hub / github.com/davidgiven/luje / replace

Method replace

lib/java/lang/String.java:1291–1303  ·  view source on GitHub ↗

Copies this string replacing occurrences of the specified character with another character. @param oldChar the character to replace. @param newChar the replacement character. @return a new string with occurrences of oldChar replaced by newChar.

(char oldChar, char newChar)

Source from the content-addressed store, hash-verified

1289 * @return a new string with occurrences of oldChar replaced by newChar.
1290 */
1291 public String replace(char oldChar, char newChar) {
1292 int index = indexOf(oldChar, 0);
1293 if (index == -1) {
1294 return this;
1295 }
1296
1297 char[] buffer = new char[count];
1298 System.arraycopy(value, offset, buffer, 0, count);
1299 do {
1300 buffer[index++] = newChar;
1301 } while ((index = indexOf(oldChar, index)) != -1);
1302 return new String(0, count, buffer);
1303 }
1304
1305 /**
1306 * Copies this string replacing occurrences of the specified target sequence

Callers 1

getAbsoluteNameMethod · 0.95

Calls 8

indexOfMethod · 0.95
arraycopyMethod · 0.95
lengthMethod · 0.95
appendMethod · 0.95
toStringMethod · 0.95
toStringMethod · 0.65
equalsMethod · 0.65
lengthMethod · 0.65

Tested by

no test coverage detected