✸ ✸ ✸
Random rd=new Random();
List<Integer> l=new ArrayList<Integer>();
for (int i =0;i <=25;i ++){
l.add( rd.nextInt(10));
}
System.out.println( l);
Collections.sort (l );
System.out.println( l);}
/* output:
[6, 4, 3, 2, 8, 1, 7, 3, 8, 1, 5, 9, 1, 4, 2, 2, 1, 2, 8, 3, 7, 2, 3, 8, 5, 0]
[0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 6, 7, 7, 8, 8, 8, 8, 9]
*/
✸ ✸ ✸
📜 版权声明
本文作者:王梓 | 原文链接:https://www.bthlt.com/note/3175905-Java生成25个随机数,并排序
出处:葫芦的运维日志 | 转载请注明出处并保留原文链接


📜 留言板
留言提交后需管理员审核通过才会显示