主要用到了java.util包下的Collections.shuffle方法

import java.util.ArrayList;
import java.util.Collections;


public class Solution {
 public static void main(String[] args) {
    int[] arr={1,2,3,4,5,6};
    ArrayList<Integer> list=new ArrayList<>();
    for(int i=0;i<arr.length;i++){
        list.add(arr[i]);
    }
    Collections.shuffle(list);
    for(int m:list){
        System.out.println(m);
    }
}
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
  • 2022-12-23
  • 2021-08-21
  • 2022-01-27
  • 2022-12-23
猜你喜欢
  • 2022-03-03
  • 2021-12-20
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案