public static void main(String[] args){
        String str="adcccdicfercbjjjjj";
        
        TreeMap<String,Integer>  tm=new TreeMap<String,Integer>();
        TreeSet<Integer>  ts=new TreeSet<Integer>();
        
//        把值保存在TreeMap中
        for(int i=0;i<str.length();i++){
            String schar=String.valueOf(str.charAt(i));
            if(!tm.containsKey(schar)){
                tm.put(schar, 1);
            }else{
                tm.put(schar, tm.get(schar)+1);
            }
        }
        
            Iterator ite=tm.keySet().iterator();
            while(ite.hasNext()){
                  String strkey=(String)ite.next();
                      ts.add(tm.get(strkey));
            }
        
          
//         System.out.println("lastvalue = "+ts.last());
//            查询重复字符最多的个数
            Iterator iteed=tm.keySet().iterator();
            while(iteed.hasNext()){
                  String strkeyed=(String)iteed.next();
                  if(tm.get(strkeyed)==ts.last()){
                      System.out.println(strkeyed+" = "+tm.get(strkeyed));
                  }
            }
          System.out.println("=====================================");
//         这里的代码备用(查询前二名重复最多的字符个数)
          Object[] intarr=ts.toArray();
            Iterator iteer=tm.keySet().iterator();
            while(iteer.hasNext()){
                  String strkeyer=(String)iteer.next();
                  if(tm.get(strkeyer)==intarr[intarr.length-1]||tm.get(strkeyer)==intarr[intarr.length-2]){
                      System.out.println(strkeyer+" = "+tm.get(strkeyer));
                  }
            }

          
    }