Java tutorial
//package com.java2s; import java.util.Arrays; public class Main { public static double[] padWithZeros(double[] input, int len, double[] output) { if (len <= input.length) { return input; } else { if (output == null || output.length != len) { output = new double[len]; } System.arraycopy(input, 0, output, 0, input.length); Arrays.fill(output, input.length, output.length, 0); return output; } } }