public static String DelStr(String str){
HashSet<Character> hs = new HashSet<Character>();
StringBuilder sb = new StringBuilder();
char[] arr = str.toCharArray();
for (int i = 0; i < arr.length; i++) {
hs.add(arr);
}
for (char c : hs) {
sb.append(c + "");
}
return sb.toString();
}
public static String DelStr(String str){
ArrayList<Character> list = new ArrayList<>();
char[] arr = str.toCharArray();
for (int i = 0; i < arr.length; i++) {
if (!list.contains(arr)) {
list.add(arr);
}
}
str = "";
for (char c : list) {
str += c + "";
}
return str;
}
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |