Java Array Create newArray(int length, double start, double increment)

Here you can find the source of newArray(int length, double start, double increment)

Description

Create and fill an array

License

Open Source License

Parameter

Parameter Description
length The length of the array
start The start
increment The increment

Return

The new array

Declaration

public static double[] newArray(int length, double start, double increment) 

Method Source Code

//package com.java2s;
/*----------------------------------------------------------------------------- 
 * GDSC SMLM Software/*w  w w .  j a  v  a  2s.  co  m*/
 * 
 * Copyright (C) 2016 Alex Herbert
 * Genome Damage and Stability Centre
 * University of Sussex, UK
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *---------------------------------------------------------------------------*/

public class Main {
    /**
     * Create and fill an array
     * 
     * @param length
     *            The length of the array
     * @param start
     *            The start
     * @param increment
     *            The increment
     * @return The new array
     */
    public static double[] newArray(int length, double start, double increment) {
        double[] data = new double[length];
        for (int i = 0; i < length; i++, start += increment)
            data[i] = start;
        return data;
    }

    /**
     * Create and fill an array
     * 
     * @param length
     *            The length of the array
     * @param start
     *            The start
     * @param increment
     *            The increment
     * @return The new array
     */
    public static int[] newArray(int length, int start, int increment) {
        int[] data = new int[length];
        for (int i = 0; i < length; i++, start += increment)
            data[i] = start;
        return data;
    }
}

Related

  1. arrayOf(T... objects)
  2. ArrayToArray(Integer obj, Integer[] objArray)
  3. ArrayToObject(byte[] values)
  4. newArray()
  5. newArray(Class elementType, int length)
  6. newArray(Object obj, int size)
  7. newArray(Object src, int len)
  8. newArray(String... args)
  9. toArray(String source, String delimiter)