根据所需的输出,当以后重复时,必须替换最初已经添加的字符,因此:
public static void uniqueCharacters(String test){ String temp = ""; for (int i = 0; i < test.length(); i++){ char current = test.charAt(i); if (temp.indexOf(current) < 0){ temp = temp + current; } else { temp = temp.replace(String.valueOf(current), ""); } } System.out.println(temp + " ");}


