Java Array Copy copyArrayAddFirst(String[] arr, String add)

Here you can find the source of copyArrayAddFirst(String[] arr, String add)

Description

Utility function that copies a string array and add another string to first

License

Apache License

Parameter

Parameter Description
arr Original array of strings
add a parameter

Return

Copied array of strings

Declaration

public static String[] copyArrayAddFirst(String[] arr, String add) 

Method Source Code

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

public class Main {
    /**/*from  w  w  w.  j  a va 2  s . c om*/
     * Utility function that copies a string array and add another string to
     * first
     * 
     * @param arr Original array of strings
     * @param add
     * @return Copied array of strings
     */
    public static String[] copyArrayAddFirst(String[] arr, String add) {
        String[] arrCopy = new String[arr.length + 1];
        arrCopy[0] = add;
        System.arraycopy(arr, 0, arrCopy, 1, arr.length);
        return arrCopy;
    }
}

Related

  1. copyArray(String[] array)
  2. copyArray(String[] originalArray)
  3. copyArray(T[] array)
  4. copyArray(T[] original)
  5. copyArray2(Object v, int len)
  6. copyArrayCutFirst(String[] arr)
  7. copyArrayExceptLast(String[] array)
  8. copyArrayMax(int[] local, int[] merged)
  9. copyArrayRange(final byte[] value, int start, int end)