62,621
社区成员
发帖
与我相关
我的任务
分享
import java.util.Arrays;
public class Test {
public static void main(String args[]) {
String str="6sabcsssfsfs33";
boolean[] removeChars = new boolean[256];
Arrays.fill(removeChars, false);
removeChars['a'] = true;
removeChars['b'] = true;
removeChars['3'] = true;
StringBuffer sb = new StringBuffer();
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if (!removeChars[ch])
sb.append(ch);
}
String result = sb.toString();
System.out.println(result);
}
}
boolean[] removeChars = new boolean[256];