Arrays.asList() doesn't work quite like I would think it should
I've included an example of the problem I've run into. I'm trying to
randomize an array of integers, much like the following program does.
Unfortunately when I ask the system to do so, I don't get a randomized
array. Now normally this wouldn't bother me. I would just assume that
a new object is being created and then destroyed by the garbage collector
without my ever seeing it, but in this case it looks like a bug.
Isn't the whole point of the asList() interface to allow this kind of
thing?
Is this a bug in Java?
--
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>
--------------------------------------------------------------------
import java.util.Arrays;
import java.util.Collections;
public class ArrayAsListTester {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int indicies[] = new int[100];
for (int index = 0; index < 100; index++) {
indicies[index] = index;
}
Collections.shuffle(Arrays.asList(indicies));
for (int index = 0; index < 100; index++) {
System.out.println(indicies[index]);
}
}
}