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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

請(qǐng)問為什么會(huì)有時(shí)候會(huì)運(yùn)行時(shí)異常

請(qǐng)問為什么會(huì)有時(shí)候會(huì)運(yùn)行時(shí)異常

hy_wang 2017-08-08 11:28:52
package?com.imooc; import?java.util.ArrayList; import?java.util.Collections; import?java.util.List; import?java.util.Random; public?class?StringSort?{ ?????List?<String>?one; ?????public?StringSort(){ ???? ?one=new?ArrayList<String>(); ?????} public?static?void?main(String[]?args)?{ //?TODO?Auto-generated?method?stub ???????/*?1創(chuàng)建完List<String>之后,往其中添加十條隨機(jī)字符串 ????????2每條字符串長(zhǎng)度為10以內(nèi)的隨機(jī)字符串 ????????3每條字符串都為隨機(jī)生成的字符,字符可以重復(fù) ????????4每條隨機(jī)字符串不可重復(fù)*/ Random?A=new?Random(); ?List<String>?one=new?ArrayList<String>(); String?B="1234567890ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz"; String?string; for(int?i=0;i<10;i++){ ?StringBuilder?C=new?StringBuilder(); ?do{ ????????????????int?D=A.nextInt(B.length()-1); ????????????????int?E=A.nextInt(10); ????????????????for(int?ii=0;ii<E;ii++){ ???????????????? C.append(B.charAt(A.nextInt(D)));} ???????????????? string?=C.toString(); ???????????????? ?}while(one.contains(string)); ?System.out.println("成功添加第"+(i+1)+"個(gè)元素:"+string); ?????????one.add(string); ? } ?????????System.out.println("----------排序前------------"); ?????????for(String?one1:one){ ???????? ?System.out.println(one.indexOf(one1) ???????? ?+one1); ?????????} System.out.println("-----------排序后-----------------");? Collections.sort(one); for(String?one1:one){ ??????? ?System.out.println(one.indexOf(one1) ??????? ?+one1); ????????} ? }} 請(qǐng)問關(guān)于這代碼有什么會(huì)出現(xiàn)異常 Exception?in?thread?"main"?java.lang.IllegalArgumentException:?bound?must?be?positive at?java.util.Random.nextInt(Random.java:388) at?com.imooc.StringSort.main(StringSort.java:31) 這是關(guān)于java第三季中6.5的練習(xí)。
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 1652 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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