Java Array Join join(Object[] objects)

Here you can find the source of join(Object[] objects)

Description

join

License

Open Source License

Declaration

public static String join(Object[] objects) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    public static String join(Object[] objects) {
        return join(objects, "");
    }/*from  www .  j av a  2  s .  co m*/

    public static String join(Object[] objects, String separator) {
        StringBuilder builder = new StringBuilder();
        int count = 0;
        for (Object object : objects) {
            if (count > 0) {
                builder.append(separator);
            }

            builder.append(object);
            count++;
        }

        return builder.toString();
    }

    public static String join(List<?> objects, String separator) {
        return join(objects.toArray(), separator);
    }

    public static String toString(Object object) {
        return ((object == null) ? "null" : object.toString());
    }
}

Related

  1. join(Object[] array, String separator)
  2. join(Object[] array, String separator)
  3. join(Object[] array, String seperator)
  4. join(Object[] elements, CharSequence separator)
  5. join(Object[] elements, String glue)
  6. join(Object[] parts, String delim)
  7. join(Object[] strings, String delimiter)
  8. join(Object[] strings, String spliter)
  9. join(Object[] tokens, String delimiter)