package it.cast.cn.set;
/*
* 1,使用Scanner从键盘读取一行输入,去掉其中重复字符, 打印出不同的那些字符*/
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;
public class Demo6 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入信息:");
String line = sc.nextLine();
sc.close();
char[] arr = line.toCharArray();
Set<Character> set = new HashSet<>();
set = new LinkedList<>();
for ( char ch : arr) {
set = add(ch);
}
for (Character character : set) {
System.out.println(character + " ");
}
}
}
22,24两行怎么错了?为什么出错。
|