I would like to add some random behavior to my code. I want to do it with the timestamp value. By this way, I want to shuffle a list with the current timestamp. This is my code:
Random random = new Random(SimClock.getIntTime());
Collections.shuffle(list, random);
Shuffle works correctly if I don't use random var to shuffle the list. However, when I use the code above the output list is always the same (it is never shuffled).
Random value changes every time Collections.shuffle is called (I checked it), so I don't know why my list is not shuffled when I use the random value. Why is this happening?
Update
list is an ArrayList with this value: [MIX0, MIX1].
This is the value of the list and of the random var when shuffle is called three times in the same execution:
randon value: 25214903885
List value before shuffle: [MIX0, MIX1]
List value after shuffle: [MIX0, MIX1]
randon value: 25214903895
List value before shuffle: [MIX0, MIX1]
List value after shuffle: [MIX0, MIX1]
randon value: 25214903865
List value before shuffle: [MIX0, MIX1]
List value after shuffle: [MIX0, MIX1]
The random value is copied from Eclipse Variables values.
When I use the shuffle method without random value the list is shuffled sometimes by this way: [MIX1, MIX0].