public class GoodCode {
//假如有字符串“6sabCSSsfsfs33” ,
//用最有快速的方法去掉字符“ab3”,不能用Java內置字符串方法(indeOf,substring,replaceAll等)?
public void isGood() {
String str = "6sabCSSsfsfs33";
char c1 = 'a';
char c2 = 'b';
char c3 = '3';
char[] c = str.toCharArray();
StringBuilder sl = new StringBuilder();
for (char temp : c) {
if (temp != c1 && temp != c2 && temp != c3)
sl.append(temp);
}
System.out.println(sl.toString());
}
public static void main(String[] args) {
GoodCode g = new GoodCode();
g.isGood();
}
} 本文鏈接http://www.cxybl.com/html/wyzz/CSS/20130310/37033.Html