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

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

這兩行代碼什么是什么意思int cursor=random.nextInt(a.length()); sb.append(a.charAt(cursor));

public class CollectionTest {


/**

* @param args

*/

List<String> stringList=new ArrayList<String>();

public void testSort(){

String a="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";

Random random=new Random();

//String s;

for(int i=0;i<10;i++){

StringBuilder sb=new StringBuilder();

do{

sb.delete(0, sb.length());

int strlen=random.nextInt(10)+1;

//if(strlen==0)continue;

for(int k=0;k<=strlen;k++) {

int cursor=random.nextInt(a.length());

sb.append(a.charAt(cursor));

}

}while(stringList.contains(sb.toString()));

stringList.add(sb.toString());

}

System.out.println("---------排序前------------");


for(String str:stringList) {


System.out.println("序列"+str);


}


Collections.sort(stringList);


System.out.println("-----排序后----------");


for(String str:stringList) {


System.out.println("序列"+str);


}


}

public static void main(String[] args) {

// TODO Auto-generated method stub

CollectionTest ec=new CollectionTest();

ec.testSort();

}


正在回答

2 回答

這里是 三位字符。 上面打錯(cuò)了~?

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

int cursor=random.nextInt(a.length());

這行代碼的意思是生成? 從 0 到? ?a 變量 長度? 之間的隨機(jī)數(shù)?

sb.append(a.charAt(cursor));

這行代碼的意思是? 從 a 變量中 獲取 隨機(jī)數(shù)位 的值??

比如 a = "abc"

生成的隨機(jī)數(shù) 就是 0 - 3 之間的? 假如生成 2?

那么就是 a變量中 第二位字符? 。 那么就是 c


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

舉報(bào)

0/150
提交
取消

這兩行代碼什么是什么意思int cursor=random.nextInt(a.length()); sb.append(a.charAt(cursor));

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

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

幫助反饋 APP下載

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

公眾號

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