mardi 30 octobre 2018

Java create arrays with random integers using for loop [duplicate]

I'm new to programming and would appreciate some help. I am trying to create multiple arrays populated with random integers and got stuck.

My ideal goal is to create 3 arrays, each size of 10, 100, 1000, filled with random integers between 100 and 1000.

Random rand = new Random();
int array10[] = new int[10];
int array100[] = new int[100];
int array1000[] = new int[1000];
int array10000[] = new int[10000];

I've been searching through and I saw people using

    int arr[][] = new int[][];

Is this something that I need to use? Or should I use a nested loop that first creates arrays, and then fill it with random numbers?




Aucun commentaire:

Enregistrer un commentaire