Java Map to String mapToString(Map acs)

Here you can find the source of mapToString(Map acs)

Description

map To String

License

Open Source License

Declaration

public static String mapToString(Map<Character, Integer> acs) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public class Main {
    public static String mapToString(Map<Character, Integer> acs) {
        StringBuilder sb = new StringBuilder();
        List<Character> keys = new ArrayList<Character>(acs.keySet());
        Collections.sort(keys);//  w w w . jav a 2s  .com
        for (Character c : keys) {
            sb.append(c);
            int count = acs.get(c);
            if (count > 1) {
                sb.append(count);
            }
        }
        return sb.toString();
    }
}

Related

  1. mapToString(Map map)
  2. mapToString(Map map)
  3. mapToString(Map map)
  4. mapToString(Map map)
  5. mapToString(Map map)
  6. mapToString(Map m)
  7. mapToString(Map map)
  8. mapToString(Map criteria)
  9. MapToString(Map map)