字符串“6sabcsssfsfs33”,掉字符“ab3”

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();
	}

}

 

你可能感兴趣的:(C++,c,C#)