I am looking to initialise a multidimensional array with random numbers between 0 and 100 (inclusive). I am able to create the multidimensional array with empty values at each field and am then able to add 100 random numbers into the available positions.
However, I would like to know if there is a way of initialising the multidimensional array with random natural integers. For example, I am looking to do it a little something like this:
double[][] array = new double[][] {{0, 1, 2} , {1, 0, 3} , {2, 3, 0}};
Is this possible? I’m thinking something along the lines of:
double[][] array = new double[][] {{random values go here},{random values go here}};
Any suggestions?
Thank you all for taking the time to read.
Mick
Create the array and then initialize it in a for loop.
Random.nextInt(n) gives you what you need.
Here’s a sample code with three different runs.
Output: