Java Array Concatenate concat(String[] array, String separator)

Here you can find the source of concat(String[] array, String separator)

Description

concat

License

Apache License

Declaration

public static String concat(String[] array, String separator) 

Method Source Code

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

import java.util.Arrays;

public class Main {
    public static <T> T[] concat(T[] first, T[] second) {
        T[] result = Arrays.copyOf(first, first.length + second.length);
        System.arraycopy(second, 0, result, first.length, second.length);
        return result;
    }//from   w  w  w  . j a  va  2s .c  o m

    public static String concat(String[] array, String separator) {
        StringBuilder sb = new StringBuilder();
        String sep = "";
        for (String s : array) {
            sb.append(sep).append(s);
            sep = separator;
        }
        return sb.toString();
    }
}

Related

  1. concat(float[] A, float[] B)
  2. concat(int[] first, int[] second)
  3. concat(int[]... arrays)
  4. concat(Object[] array)
  5. concat(Object[] first, Object second)
  6. concat(String[] parts)
  7. concat(String[] strs)
  8. concat(String[]... arrays)
  9. concat(T val, T[] vals)