使用Java从给定范围生成shuffle

时间:2014-12-29 03:18:09

标签: android

 int start = 40;
 int end = 50;
 for (int i = start; i <= end; i++)
 System.out.println(i);

输出:: 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

我知道我问一个愚蠢的问题

但我不知道如何通过collection.shuffle方法来改变它 请解释 专家

1 个答案:

答案 0 :(得分:0)

一个简单的解决方案是:

List subList = arrayList.subList(startIndex, endIndex);
Collections.shuffle(subList);