Over a million developers have joined DZone.

Join In Java

DZone's Guide to

Join In Java

· ·
Free Resource
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();

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}