Java Array Join join(Object[] arguments)

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

Description

join

License

Apache License

Declaration

public static String join(Object[] arguments) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class Main {
    public static String join(Object[] arguments) {
        return join(Arrays.asList(arguments));
    }//from  w  ww  .  j  a va 2s .  c  om

    public static String join(Object[] arguments, String glue) {
        return join(Arrays.asList(arguments), glue);
    }

    public static String join(List<Object> arguments) {
        return join(arguments, ", ");
    }

    public static String join(List<Object> arguments, String glue) {
        if (arguments == null) {
            return "";
        }
        StringBuilder output = new StringBuilder();
        Iterator<Object> it = arguments.iterator();
        while (it.hasNext()) {
            output.append(it.next().toString());
            if (it.hasNext()) {
                output.append(glue);
            }
        }
        return output.toString();
    }
}

Related

  1. join(final T[] collection)
  2. join(int[] array, String separator)
  3. join(int[] follows)
  4. join(long[] a, long[] b)
  5. join(long[] array, String delim)
  6. join(Object[] arr)
  7. join(Object[] arr, String separator)
  8. join(Object[] arr, String separator)
  9. join(Object[] array)