随机改组阵列我需要随机调整以下数组:int[] solutionArray = {1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1};这有什么功能吗?
4 回答

智慧大石
TA贡献1946条经验 获得超3个赞
这是一个使用的简单方法ArrayList
:
List<Integer> solution = new ArrayList<>();for (int i = 1; i <= 6; i++) { solution.add(i);}Collections.shuffle(solution);
添加回答
举报
0/150
提交
取消