This site requires JavaScript, please enable it in your browser!
Greenfoot back
ORSODO
ORSODO wrote ...

2018/2/12

Random Array

ORSODO ORSODO

2018/2/12

#
Is there any random array generator in Greenfoot? If not, how can I program it?
xbLank xbLank

2018/2/12

#
Random array generator? What do you mean.
danpost danpost

2018/2/12

#
Something like this:
// with a declared array
int[] array = new int[10]; // array for the choices to be made randomly

// add random values and shuffle
for (int i=0; i<array.length; i++) array[i] = i; // fill array
java.util.Collections.shuffle(java.util.Arrays.asList(array)); // shuffle array
ORSODO ORSODO

2018/2/12

#
Thank youu! :D
You need to login to post a reply.