Skip to content

Instantly share code, notes, and snippets.

@libliboom
Last active November 4, 2019 07:21
Show Gist options
  • Save libliboom/3721b896a530bcb7a3f0575b9db2eb2d to your computer and use it in GitHub Desktop.
Save libliboom/3721b896a530bcb7a3f0575b9db2eb2d to your computer and use it in GitHub Desktop.
public String substring(int beginIndex) {
if (beginIndex < 0) {
throw new StringIndexOutOfBoundsException(beginIndex);
}
int subLen = value.length - beginIndex;
if (subLen < 0) {
throw new StringIndexOutOfBoundsException(subLen);
}
return (beginIndex == 0) ? this : new String(value, beginIndex, subLen);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment