A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

public Map<String, Integer> getCount(String str){
                Map<String, Integer> map = new HashMap<String, Integer>();
                if(!str.isEmpty()){
                        for(int i=0;i<str.length();i++){
                                String key = str.charAt(i)+"";
                                if(map.containsKey(key)){
                                        int init = map.get(key);
                                        map.put(key, init+=1);
                                }else{
                                        map.put(key, 1);
                                }
                        }
                }
               
               
               
                return map;
        }

2 个回复

倒序浏览
回复 使用道具 举报
面试的时候遇到这道题了
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马