int is a basic data-type not an object ( class that extends java.lang.Object ). since asList requires Object[] (see error) you'd have to use Integer[] instead. now eveytime you would use one of these Integers as color you'd have to do Integer.intValue() which complicates things a bit:
Code:
Integer[] toShuffle = new Integer[]{
new Integer(1),
new Integer(2),
new Integer(3),
new Integer(4),
new Integer(5),
new Integer(6)
};
Collections.shuffle(Arrays.asList(toShuffle));
println( toShuffle );
println( toShuffle[0].intValue() );
i recommend writing your own shuffle function .. something like:
Code:
int[] toShuffle = {
0,1,2,3,4,5,6,7,8};
int[] shuffled = new int[toShuffle.length];
int i=0;
while ( toShuffle.length > 0 )
{
int rnd = int(random(toShuffle.length)); // by default random() never returns the given max value
shuffled[i] = toShuffle[rnd];
i++;
if ( rnd > 0 && rnd < toShuffle.length-1 )
toShuffle = concat(subset(toShuffle,0,rnd), subset(toShuffle,rnd+1,toShuffle.length-rnd-1));
else if ( rnd == 0 )
toShuffle = subset(toShuffle,1,toShuffle.length-1);
else
toShuffle = shorten( toShuffle );
}
println( shuffled );