samedi 18 novembre 2017

How to shuffle a simple array

I've googled this question all day yesterday and still can't get an idea on how to do what I need. Basically, I've declared an integer array and, to make it simple, it only has three elements from 0 to 2. All i need to do is shuffle them 100,000 times. Here's my unfinished code. I know I need to make a for loop and import java.util.Random, however I have no clue what to do under the for loop. Again, I need it to shuffle 100,000 times. Thanks for all the help!

int [] arrayTest = new int [3];
arraytest[0] = 0;
arraytest[1] = 1;
arraytest[2] = 2;

//for loop goes here

System.out.println(arrayTest[0] + arrayTest[1] + arrayTest[2]);




Aucun commentaire:

Enregistrer un commentaire