Java Utililty Methods Map Print

List of utility methods to do Map Print

Description

The list of methods to do Map Print are organized into topic(s).

Method

voidprintMap(Map mp)
print Map
Iterator it = mp.entrySet().iterator();
while (it.hasNext()) {
    Map.Entry pairs = (Map.Entry) it.next();
    it.remove(); 
StringprintMap(Map theMap)
print Map
StringBuilder theBuf = new StringBuilder();
for (Map.Entry<? extends K, ? extends V> entry : theMap.entrySet()) {
    theBuf.append(entry.getKey());
    theBuf.append(" --> ");
    theBuf.append(entry.getValue());
    theBuf.append(System.getProperty("line.separator"));
return theBuf.toString();
...
voidprintMap(Map mp)
print Map
Iterator<?> it = mp.entrySet().iterator();
while (it.hasNext()) {
    Entry<?, ?> pairs = (Entry<?, ?>) it.next();
    Object obj = pairs.getValue();
    if (obj instanceof int[]) {
        int[] seq = (int[]) obj;
        System.out.print(pairs.getKey() + " =");
        for (int i = 0; i < seq.length; ++i) {
...
voidprintMap(Map map)
print Map
if (map == null) {
    System.out.println("NULL");
    return;
if (map.size() == 0) {
    System.out.println("EMPTY");
    return;
for (Map.Entry<K, V> entry : map.entrySet()) {
    System.out.println(entry.getKey() + " = " + entry.getValue());
voidprintMap(Map map)
print Map
Set<Map.Entry<K, V>> resultsEntry = map.entrySet();
Iterator<Map.Entry<K, V>> iter = resultsEntry.iterator();
while (iter.hasNext()) {
    Map.Entry<K, V> result = iter.next();
    System.out.println(result.getKey() + " = " + result.getValue());
voidprintMap(Map map)
To print given maps content with System.out.println, both keys and values are printed.
Set<Entry<Object, Object>> s = map.entrySet();
Iterator<Entry<Object, Object>> it = s.iterator();
while (it.hasNext()) {
    Map.Entry entry = it.next();
    Object key = entry.getKey();
    Object value = entry.getValue();
    System.out.println(key.toString() + " => " + value.toString());
voidprintMap(Map map)
print Map
for (Object key : map.keySet()) {
    println("key: " + key + " value: " + map.get(key));
voidprintMap(Map map)
print Map
for (Map.Entry<String, Integer> entry : map.entrySet()) {
    System.out.println("[Key] : " + entry.getKey() + " [Value] : " + entry.getValue());
StringBuilderprintMap(Map map)
print Map
StringBuilder strBuilder = new StringBuilder();
Set<String> keySet = map.keySet();
List<String> keys = new ArrayList<>(keySet);
strBuilder.append("{");
for (String key : keys) {
    strBuilder.append("\"" + key + "\":");
    strBuilder.append(map.get(key).toString());
    if (!key.equals(keys.get(keys.size() - 1))) {
...
voidprintMap(Map map, int depth)
Prints the map.
String log = "Parent";
if (depth > 0) {
    log = "Children";
StringBuilder str = new StringBuilder();
int loop = depth;
while (loop > 0) {
    str.append('\t');
...