如何去除重复的字符串? 可以考虑考虑集合是如何保证元素不重复的。作为参考!
package www.wlkankan.cn public class Test { private static final Object object = new Object(); public static void main(String[] args) { //利用map的key不能重复 Map<Object, Object> map = Maps.newLinkedHashMap(); //将字符串进行肢解 char[] str = "abcdefgabcdefgoop".toCharArray(); //将直接后的内容用作map的key for (int i = 0; i < str.length; i++) map.put(str[i], object); //最终的字符串 StringBuilder builder = new StringBuilder(); //便利最后获得到的map,重新组装到字符串 for (Map.Entry<Object, Object> entry : map.entrySet()) builder.append(entry.getKey()); System.out.println(builder.toString()); } }