How to get random range number in set

后端 未结 3 1643
你的背包
你的背包 2021-01-21 12:26

I have 100 record [1 -> 100], i want get random 50 record in this, how to do in java? Thanks.

3条回答
  •  感情败类
    2021-01-21 13:27

    Set set;
    
    List list = new ArrayList(set);
    Collections.shuffle(list);
    List random50 = list.subList(0, 50);
    

提交回复
热议问题