第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

6-5交作業(yè)了

package?com.imooc.collectionandmap;

import?org.apache.commons.lang3.RandomStringUtils;

import?java.util.ArrayList;
import?java.util.List;
import?java.util.Random;

/**
?*?練習(xí)6-5:利用Collections.sort()方法對(duì)泛型為String的List進(jìn)行排序升級(jí)
?*?1、創(chuàng)建完List<String>之后,往其中添加十條隨機(jī)字符串
?*?2、每條字符串的長(zhǎng)度為10以?xún)?nèi)的隨機(jī)整數(shù)
?*?3、每條字符串的每個(gè)字符都為隨機(jī)生成的字符,字符可以重復(fù)
?*?4、每條隨機(jī)字符串不可重復(fù)
?*/

public?class?StudentTestSort?{

????public?void?testSort()?{
????????List<String>?list?=?new?ArrayList<String>();
????????Random?random?=?new?Random();
????????Integer?k;
????????String?stb;
????????for?(int?i?=?0;?i?<?10;?i++)?{
????????????do?{
????????????????k?=?random.nextInt(10);
????????????????stb?=?RandomStringUtils.randomAlphanumeric(k);
????????????}while?(list.contains(stb)?||?stb?==?"");
????????????list.add(stb);
????????????System.out.println("成功添加字符串"?+?(i+1)?+?":"?+?stb);
????????}
????????for?(String?st?:?list)?{
????????????System.out.println("元素為:"?+?st);
????????}
????}

????public?static?void?main(String[]?args)?{
????????StudentTestSort?sort?=?new?StudentTestSort();
????????sort.testSort();
????}
}


正在回答

舉報(bào)

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

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

進(jì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)