Fill an array with random numbers

后端 未结 13 2277
感动是毒
感动是毒 2020-12-03 11:54

I need to create an array using a constructor, add a method to print the array as a sequence and a method to fill the array with random numbers of the type double.

He

13条回答
  •  悲哀的现实
    2020-12-03 12:24

    Try this:

    public void double randomFill() {
        Random rand = new Random();
        for (int i = 0; i < this.anArray.length(); i++)
            this.anArray[i] = rand.nextInt();
    }
    

提交回复
热议问题