第二题 public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String line = scanner.nextLine(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < line.length(); i++) { if (sb.indexOf(line.charAt(i) + "") == -1) { sb.append(line.charAt(i)); } } System.out.println(sb.toString()); }