Map中取得Map的key值和value值

//将返回的Map的key 拼成空格隔开的字符串
	private static String map2String(List<Map> arr){
		String str = "";
		for (Map<String, Integer>  m : arr) {
			Set<String> s = m.keySet();
			for (String string : s) {
				str += string + " ";
			}
		}
		return str;
	}


Map<String, String> params = new HashMap<String,String>();
params.put("task_id", task_id);
StringBuffer sb = new StringBuffer();
if (params != null) {
			for (Entry<String, String> e : params.entrySet()) {
				sb.append(e.getKey());
				sb.append("=");
				sb.append(e.getValue());
				sb.append("&");
			}
			sb.substring(0, sb.length() - 1);
		}

你可能感兴趣的:(java MAP)