Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Join objects using toString()
     *
     * @param delimiter
     *            the delimiter
     * @param objects
     *            the objects
     * @return the string
     */
    public static String joinObjects(String delimiter, Iterable<?> objects) {
        StringBuilder sb = new StringBuilder();
        boolean first = true;
        for (Object object : objects) {
            if (first) {
                first = false;
            } else {
                sb.append(delimiter);
            }
            sb.append(object.toString());
        }
        return sb.toString();
    }
}