LinkedHashSet实现去重和有序

import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        Set<Character> set = new LinkedHashSet<>();
        char[] c = s.toCharArray();
        for(int i = 0; i<c.length; i++){
            set.add(c[c.length-1-i]);
        }
        for(char ch : set){
            System.out.print(ch);
        }
    }
}