import java.util.LinkedHashSet;
import java.util.Scanner;
public class LinkedHashSetTest02 {
public static void main(String[] args) {
LinkedHashSet<Character> lhs = new LinkedHashSet<>();
Scanner sc= new Scanner(System.in);
System.out.println("请输入一个字符串");
String s = sc.next();
for (int i = 0; i < s.length(); i++) {
char[] chs = s.toCharArray();
lhs.add(chs);
}
for(Character c:lhs) {
System.out.println(c);
}
}
}
|
|