Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static List join(Map map, String separator) {
        if (map == null)
            return null;
        List list = new ArrayList();
        if (map == null || map.size() == 0)
            return list;
        for (Iterator i$ = map.entrySet().iterator(); i$.hasNext();) {
            java.util.Map.Entry entry = (java.util.Map.Entry) i$.next();
            String key = (String) entry.getKey();
            String value = (String) entry.getValue();
            if (value == null || value.length() == 0)
                list.add(key);
            else
                list.add((new StringBuilder()).append(key).append(separator).append(value).toString());
        }

        return list;
    }

    public static String join(List list, String separator) {
        StringBuilder sb = new StringBuilder();
        String ele;
        for (Iterator i$ = list.iterator(); i$.hasNext(); sb.append(ele)) {
            ele = (String) i$.next();
            if (sb.length() > 0)
                sb.append(separator);
        }

        return sb.toString();
    }
}