Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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();
    }
}