replaceLastNCharacters method
Returns a new string with the last n characters replaced by
replacementChar.
Implementation
@useResult
String replaceLastNCharacters(int n, String replacementChar) {
if (n <= 0 || n > length) {
return this;
}
return substringSafe(0, length - n) + replacementChar * n;
}