get Random Array - Java Collection Framework

Java examples for Collection Framework:Array Element

Description

get Random Array

Demo Code


//package com.java2s;

import java.util.Random;

public class Main {
    private static Random random = new Random(400);

    public static double[] getRandomArray(int size, double lowBound,
            double highBound) {
        double[] ret = new double[size];
        for (int i = 0; i < size; i++) {
            ret[i] = random() * (highBound - lowBound) + lowBound;
        }/*from   w w w .j  ava 2 s  .c  o m*/
        return ret;
    }

    public static double random() {
        return random.nextDouble();
    }
}

Related Tutorials