Java Array Concatenate concatArray(String[] array, String glue)

Here you can find the source of concatArray(String[] array, String glue)

Description

concat Array

License

Open Source License

Declaration

public static String concatArray(String[] array, String glue) 

Method Source Code

//package com.java2s;

public class Main {
    public static String concatArray(String[] array, String glue) {
        StringBuilder sb = new StringBuilder();
        for (String s : array) {
            sb.append(s);//from w w w. j a va 2 s .c om
            sb.append(glue);
        }
        return sb.toString().substring(0, sb.toString().lastIndexOf(glue));
    }

    public static String concatArray(String[] array, String glue, int start) {
        String[] narray = new String[array.length - start];
        int pointer = 0;
        for (int i = start; i < array.length; i++) {
            narray[pointer] = array[i];
            pointer++;
        }
        return concatArray(narray, glue);
    }
}

Related

  1. concatArray(Object... objects)
  2. concatArray(Object[] arr1, Object newValue)
  3. concatArray(String string, String[] words)
  4. concatArray(String[] array, int start)
  5. concatArray(String[] array, int start, String def)
  6. concatArray(T[] first, T[]... rest)
  7. concatArrays(byte[] a, byte[] b)
  8. concatArrays(byte[]... arrays)
  9. concatArrays(byte[]... arrays)