Java tutorial
//package com.java2s; import java.util.Map; public class Main { public static String build(Map<String, String> conditions) { if (conditions.isEmpty()) { return null; } StringBuilder conditionBuilder = new StringBuilder(); int count = 0; for (Map.Entry<String, String> condition : conditions.entrySet()) { conditionBuilder.append(condition.getKey()); conditionBuilder.append("="); conditionBuilder.append(condition.getValue()); if (count < conditions.entrySet().size() - 1) { conditionBuilder.append("&"); } count++; } return conditionBuilder.toString(); } }