You can use another method to remove the specified characters in a string? Replace it with "". The Code is as follows: String s = "?????! Http://t.cn/zlkjUY5 ??????? "; Int idex = 0; s = s. replaceAll ("? "," "); System. out. println (s); Result :! The following is a slightly complex usage of the http://t.cn/zlkjUY5: public static String getString (String str) {// define a set to store the decomposed Character List <String> list = new ArrayList <String> (); String streee = ""; for (int I = 0; I <str. length (); I ++) {streee = str. substring (I, I + 1); list. add (streee) ;}// define a StringBuffer strb = new StringBuffer (); for (int j = 0; j <list. size (); j ++) {String a = list. get (j ). toString ();// If not? Add this character to the StringBuffer if (! A. equals ("? ") {Strb. append (a) ;}else {}} System. out. println (strb); return strb. toString ();}