HashMap的基础知识

   if(!chatHistoryMap.containsKey(type)) {
            chatHistoryMap.put(type,new ArrayList<>());
        }
        List<String> chatIds = chatHistoryMap.get(type);

等同于:

List<String> chatIds = chatHistoryMap.computeIfAbsent(type, k -> new ArrayList<>());

posted @ 2025-08-15 10:24  蒟蒻00  阅读(10)  评论(0)    收藏  举报