隨機改組陣列我需要隨機調整以下數組: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
提交
取消