Over a million developers have joined DZone.

Join In Java

Join a collection of objects into a String using the specified delimiter.  One thing to note is that the collection can contain any object.  The object's toString() method will be used to convert said object to its String representation.

    public static String join(Collection s, String delimiter) {
        StringBuffer buffer = new StringBuffer();
        Iterator iter = s.iterator();
        while (iter.hasNext()) {
            if (iter.hasNext()) {
        return buffer.toString();

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}