Here you can find the source of copyAndFillOf(T[] original, int newLength, T padding)
static public <T> T[] copyAndFillOf(T[] original, int newLength, T padding)
//package com.java2s; //License from project: Apache License import java.util.Arrays; public class Main { static public <T> T[] copyAndFillOf(T[] original, int newLength, T padding) {/*from w w w. j a v a2 s .co m*/ if (newLength < 0) throw new NegativeArraySizeException( "The array size is negative."); T[] newArray = Arrays.copyOf(original, newLength); if (original.length < newLength) { System.arraycopy(original, 0, newArray, 0, original.length); Arrays.fill(newArray, original.length, newArray.length, padding); } else System.arraycopy(original, 0, newArray, 0, newLength); return newArray; } static public double[] copyAndFillOf(double[] original, int newLength, double padding) { if (newLength < 0) throw new NegativeArraySizeException( "The array size is negative."); double[] newArray = new double[newLength]; if (original.length < newLength) { System.arraycopy(original, 0, newArray, 0, original.length); Arrays.fill(newArray, original.length, newArray.length, padding); } else System.arraycopy(original, 0, newArray, 0, newLength); return newArray; } static public long[] copyAndFillOf(long[] original, int newLength, long padding) { if (newLength < 0) throw new NegativeArraySizeException( "The array size is negative."); long[] newArray = new long[newLength]; if (original.length < newLength) { System.arraycopy(original, 0, newArray, 0, original.length); Arrays.fill(newArray, original.length, newArray.length, padding); } else System.arraycopy(original, 0, newArray, 0, newLength); return newArray; } }