只要第一个,所以要用LinkedHashMap,保证加入的顺序

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) { 
            String str= in.nextLine();
            Map<String,Integer> map = new LinkedHashMap<>();
            for(int i=0;i<str.length();i++){
                String key = str.substring(i,i+1);
                if (map.containsKey(key)){
                    map.put(key,map.get(key) + 1);
                }
                else
                {
                    map.put(key,1);
                }
            }
            String result = "-1";
            for(String k : map.keySet())
            {
                if (map.get(k) == 1){
                    result = k;
                    break;
                }
            }
            System.out.println(result);
        }
    }
}