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 String dump(Map in) {
        if (in == null)
            return "null";
        StringBuilder sb = new StringBuilder("{");
        for (Iterator it = in.keySet().iterator(); it.hasNext();) {
            String key = (String) it.next();
            sb.append(key).append(":").append(in.get(key));
            if (it.hasNext())
                sb.append(", ");
        }
        sb.append("}");
        return sb.toString();
    }

    public static String dump(List<?> list) {
        return list == null ? "null" : new StringBuffer("[").append(concat(list, ", ")).append("]").toString();
    }

    public static String dump(int[] oar) {
        if (oar == null)
            return "null";
        StringBuffer sb = new StringBuffer("[");
        for (int i = 0; i < oar.length; i++) {
            if (i != 0)
                sb.append(", ");
            sb.append(oar[i]);

        }
        sb.append("]");
        return sb.toString();
    }

    public static String dump(Object[] oar) {
        if (oar == null)
            return "null";
        StringBuffer sb = new StringBuffer("[");
        for (int i = 0; i < oar.length; i++) {
            if (i != 0)
                sb.append(", ");
            sb.append(oar[i]);

        }
        sb.append("]");
        return sb.toString();
    }

    public static String concat(List<?> list, String separator) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < list.size(); i++) {
            if (i != 0)
                sb.append(separator);
            sb.append(list.get(i));
        }
        return sb.toString();
    }

    public static String concat(Iterable<?> list, String separator) {
        StringBuffer sb = new StringBuffer();
        int i = 0;
        for (Object o : list) {
            if (i != 0)
                sb.append(separator);
            sb.append(o);
            i++;
        }
        return sb.toString();
    }

    public static String concat(Object[] array, String separator) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < array.length; i++) {
            if (i != 0)
                sb.append(separator);
            sb.append(array[i]);
        }
        return sb.toString();
    }

    public static String concat(int[] array, String separator) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < array.length; i++) {
            if (i != 0)
                sb.append(separator);
            sb.append(array[i]);
        }
        return sb.toString();
    }
}