标签:lis har 不重复 cat ring main ret contains remove
public class Main{
public static void main(String[] args) {
String string = "afjhafadfgfas";
String string1 = RemoveDuplication(string);
System.out.println(string1);
}
public static String RemoveDuplication(String string) {
//创建一个数组用于存放没有重复的字符串
List list = new ArrayList();
for (int i = 0; i < string.length(); i++) {
//如果list已经有该字符了,则调到下一次循环
if (list.contains(string.charAt(i))) {
continue;
} else {
//否则都是不重复的字符,加入list中
list.add(string.charAt(i));
}
}
return list.toString();
}
}
标签:lis har 不重复 cat ring main ret contains remove
原文地址:http://www.cnblogs.com/peng2017615/p/7571687.html