集册 Java实例教程 获取随机数组

获取随机数组

欢马劈雪     最近更新时间:2020-01-02 10:19:05

474
获取随机数组


//package com.nowjava;


import java.util.Random;//N o  w  J a v a . c o m - 时  代  Java


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;

        }

        return ret;

    }
//N o w J a v a . c o m - 时代Java

   
展开阅读全文