问题其实蛮简答的,在一些正式的文本中,经常会出现比如 first, second: finally,当TOKEN 这些词组之后,后缀会产生一些不好的影响。所以我想写一小代码,能够判断和过滤最后一个非字母的字符。代码如下:public class cal {

public static void main(String[] args) {
String info = "from"; if(info.length()!=0){
char endLetter = info.charAt(info.length()-1); if(!(endLetter >= 'A' && endLetter <= 'Z') || (endLetter >= 'a' && endLetter <= 'z')){
String newWord = "";
for(int i = 0 ;i<info.length()-1;i++){
newWord +=info.charAt(i);
}
System.out.println("new " + newWord);
}
else{
System.out.println("old " + info);
}
}
}
}现在的问题是,如果正常的字符,(后缀为字母)也会进入到IF的表达式中,EP:输入:from,会被过滤成fro
请教一下,错误在哪里??