//class StringEditor
public class StringEditor
{
public static String removeNonLetters(String original)
{
StringBuffer aBuffer=new StringBuffer(original.length());
char aCharacter;
for(int i=0;i<original.length();i++)
{
aCharacter=original.charAt(i);
if(Character.isLetter(aCharacter))
{
aBuffer.append(new Character(aCharacter));
}
}
return new String(aBuffer);
}
}
//class StringEditorTester
public class StringEditorTester
{
public static void main(String args[])
{
String original="hello123,my name is mark,234i think you are my classmate?!!";
System.out.println(StringEditor.removeNonLetters(original));
}
}
结果