package edu.eurasia.list.collection; import java.util.*; /** * 类名:
* 功能:(字符随机数排序)
* 作者:admin
* 日期:2018/7/16 */ public class CollectionTest { /** * 对Integer泛型进行排序 */ public void testSort1(){ ListintegerList = new ArrayList(); //插入随机数 Random random = new Random(); Integer k; for (int i = 0; i stringList = new ArrayList(); stringList.add("microsoft"); stringList.add("google"); stringList.add("lenovo"); System.out.println("-------------排序前----------"); for (String string:stringList ) { System.out.println("元素" + string); } Collections.sort(stringList); System.out.println("-------------排序后----------"); for (String string:stringList ) { System.out.println("元素" + string); } } /** * 创建完List 之后,往其中添加10条随机字符串 * 每条字符串的长度为10以内的随机整数 * 每条字符串的每个字符都为随机生成的字符,字符可以重复 * 每条随机字符串不可重复 * */ public void homework(){ List stringList = new ArrayList(); int length = 10; String str = "zxcvbnmlkjhgfdsaqwertyuiopQWERTYUIOPASDFGHJKLZXCVBNM1234567890"; for (int i =0;i
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1369/viewspace-2804612/ ,如需转载,请注明出处,否则将追究法律责任。