哭爹喊娘学Java
2019-08-09 10:09
public void testSort3(){ List<String> strList = new ArrayList<String>(); String basicStr = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random random = new Random(); for(int i =0;i < 10;i++){ StringBuffer sbf = new StringBuffer(); int length = random.nextInt(10) + 1; for(int j = 0;j < length;j++){ int charID = random.nextInt(basicStr.length()); sbf.append(basicStr.charAt(charID)); } if(!strList.contains(sbf.toString())){ System.out.println("添加字符串:" + sbf.toString()); strList.add(sbf.toString()); } } System.out.println("------排序后------"); Collections.sort(strList); for(String str:strList){ System.out.println("元素为:" + str); } }
int length = random.nextInt(10) + 1;
请问这一行是什么意思呢
Java入门第三季
409792 学习 · 4340 问题
相似问题