Java Map to String mapToString(Map map)

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

Description

map To String

License

Open Source License

Declaration

public static String mapToString(Map<?, ?> map) 

Method Source Code


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

import java.util.*;

public class Main {
    public static String mapToString(Map<?, ?> map) {
        if (map.isEmpty()) {
            return "";
        }//  w  w  w .  ja  va  2  s  . co  m
        StringBuilder stringBuilder = new StringBuilder();
        boolean notFirst = false;
        for (Map.Entry<?, ?> entry : map.entrySet()) {
            if (notFirst) {
                stringBuilder.append(',');
            }
            stringBuilder.append(entry.getKey().toString()).append(':').append(entry.getValue().toString());
            notFirst = true;
        }
        return stringBuilder.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 map)
  7. mapToString(Map map)
  8. mapToString(Map acs)
  9. mapToString(Map m)