为什么不只是
String substr = word.substring(word.length() - 3)?
更新资料
String在致电之前,请确保您检查的长度至少为3个字符
substring():
if (word.length() == 3) { return word;} else if (word.length() > 3) { return word.substring(word.length() - 3);} else { // whatever is appropriate in this case throw new IllegalArgumentException("word has less than 3 characters!");}


