标签:als array 使用字符串 proc log rem ext blog ado
import java.util.*;
public class Main {
public static void main(String[] args) {
String str = "AABBCADDDACCCCCC";
System.out.println(filterCode2(str));
}
public static String filterCode2(String str) {
List<String> list = new ArrayList<String>();
for (int i = 0; i < str.length(); i++) {
list.add(str.charAt(i) + "");// 这里就是使用字符串存入到list中,
}
for (int m = 0; m < list.size() - 1; m++) {
if (list.get(m).equals(list.get(m + 1))) {
list.remove(m + 1);
list.remove(m);
m--;
}
}
StringBuffer sb = new StringBuffer();
String str3 = "";
for (int j = 0; j < list.size(); j++) {
str3 = sb.append(list.get(j)).toString();
}
return str3;
}
}
标签:als array 使用字符串 proc log rem ext blog ado
原文地址:http://blog.51cto.com/13579083/2330134