Java Array Fill fillArray(int arrayLength)

Here you can find the source of fillArray(int arrayLength)

Description

Fills An array with zeros

License

Open Source License

Parameter

Parameter Description
arrayLength The length of the desired array

Return

The filled array

Declaration

public static double[] fillArray(int arrayLength) 

Method Source Code

//package com.java2s;
/*/*from  w w w.j ava  2  s. co m*/
 * Copyright (c) 2014 mgamelabs
 * To see our full license terms, please visit https://github.com/mgamelabs/mengine/blob/master/LICENSE.md
 * All rights reserved.
 */

public class Main {
    /**
     * Fills An array with zeros
     *
     * @param arrayLength The length of the desired array
     * @return The filled array
     */
    public static double[] fillArray(int arrayLength) {
        return fillArray(arrayLength, 0);
    }

    /**
     * Fills an array with custom numbers
     *
     * @param arrayLength The length of the desired array
     * @param placeholder The desired number to fill the array with
     * @return The filled array
     */
    public static double[] fillArray(int arrayLength, double placeholder) {

        double[] output = new double[arrayLength];
        for (int i = 0; i < arrayLength; i++)
            output[i] = placeholder;
        return output;

    }
}

Related

  1. fillArray(char[] array, int offset, char value)
  2. fillArray(double[][][] array, double[] value, int rows, int columns)
  3. fillArray(final float[] array, final float value)
  4. fillArray(float filling, int length)
  5. fillArray(float[] batchVertices, float f)
  6. fillArray(int min, int max)
  7. fillArray(int size, Float value)
  8. fillArray(int value, int length)
  9. fillArray(int[] array, int value)