在Java中,我知道要对一个ArrayList进行洗牌,方法Collections.shuffle()存在,但是这会洗牌整个列表.
我怎么能写一个方法(或者,有人可以写它并给我看吗?)如下:
private ArrayList<AnObject> list;
/**
* Shuffles the concents of the array list in the range [start, end], and
* does not do anything to the other indicies of the list.
*/
public void shuffleArrayListInTheRange(int start, int end)
Run Code Online (Sandbox Code Playgroud)