最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

來(lái)交個(gè)作業(yè)

package?com.imooc.collection;

import?java.util.*;

public?class?CollectionsTest?{


????/**
?????*?創(chuàng)建String泛型的List,放入10條隨機(jī)的字符串
?????*?每條字符串的長(zhǎng)度為10以?xún)?nèi)的隨機(jī)整數(shù)
?????*?每條字符串的字符都是隨機(jī)生成的字符,可以重復(fù)
?????*?每條隨機(jī)生成的字符串不可以重復(fù)
?????*?@param?args
?????*/
????public?void?testSort2(){
????????List<String>?stringList?=?new?ArrayList<String>();
????????String?strDict="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
????????Random?randomInt?=?new?Random();
????????Integer?len;

????????for?(int?i?=?0;?i?<?10;?++?i){
????????????len?=?randomInt.nextInt(10);
????????????String?newStr;
????????????do?{
????????????????StringBuffer?sb?=?new?StringBuffer();
????????????????for?(int?j?=?0;?j?<?len;?++j)?{
????????????????????int?k?=?randomInt.nextInt(strDict.length());
????????????????????sb.append(strDict.charAt(k));
????????????????}
????????????????newStr?=?sb.toString();
????????????}while?(stringList.contains(newStr));
????????????stringList.add(newStr);
????????????System.out.println("成功添加字符串:"?+?newStr);
????????}

????????System.out.println("------------------排序前-------------------");
????????for(String?i?:?stringList){
????????????System.out.println("元素為:"?+?i);
????????}
????????Collections.sort(stringList);
????????System.out.println("------------------排序后-------------------");
????????for(String?i?:?stringList){
????????????System.out.println("元素為:"?+?i);
????????}
????}

????public?static?void?main(String[]?args)?{
????????CollectionsTest?ct1?=?new?CollectionsTest();
????????ct1.testSort2();
????}
}


正在回答

1 回答


package?com.imooc.collection;?import?java.util.*;?public?class?CollectionsTest?{??????/**?????*?創(chuàng)建String泛型的List,放入10條隨機(jī)的字符串?????*?每條字符串的長(zhǎng)度為10以?xún)?nèi)的隨機(jī)整數(shù)?????*?每條字符串的字符都是隨機(jī)生成的字符,可以重復(fù)?????*?每條隨機(jī)生成的字符串不可以重復(fù)?????*?@param?args?????*/????public?void?testSort2(){????????List<String>?stringList?=?new?ArrayList<String>();????????String?strDict="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";????????Random?randomInt?=?new?Random();????????Integer?len;?????????for?(int?i?=?0;?i?<?10;?++?i){????????????len?=?randomInt.nextInt(10);????????????String?newStr;????????????do?{????????????????StringBuffer?sb?=?new?StringBuffer();????????????????for?(int?j?=?0;?j?<?len;?++j)?{????????????????????int?k?=?randomInt.nextInt(strDict.length());????????????????????sb.append(strDict.charAt(k));????????????????}????????????????newStr?=?sb.toString();????????????}while?(stringList.contains(newStr));????????????stringList.add(newStr);????????????System.out.println("成功添加字符串:"?+?newStr);????????}?????????System.out.println("------------------排序前-------------------");????????for(String?i?:?stringList){????????????System.out.println("元素為:"?+?i);????????}????????Collections.sort(stringList);????????System.out.println("------------------排序后-------------------");????????for(String?i?:?stringList){????????????System.out.println("元素為:"?+?i);????????}????}?????public?static?void?main(String[]?args)?{????????CollectionsTest?ct1?=?new?CollectionsTest();????????ct1.testSort2();????}}

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Java入門(mén)第三季
  • 參與學(xué)習(xí)       409775    人
  • 解答問(wèn)題       4546    個(gè)

Java中你必須懂得常用技能,不容錯(cuò)過(guò)的精彩,快來(lái)加入吧

進(jìn)入課程

來(lái)交個(gè)作業(yè)

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)