亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么這樣寫會報str cannot be resolved to a variable錯

為什么這樣寫會報str cannot be resolved to a variable錯

codeboy__ 2017-04-10 18:01:22
public void testSort3() { List<Student> studentList = new ArrayList<Student>();//學生集合 List<String> studentIdList = new ArrayList<String>();//學生ID集合 //生成隨機不重復的1000以內ID Random rand = new Random(); for (int i = 0; i < 3; i++) { //String str; do { String ?str = new String(rand.nextInt(1000) + ""); } while (studentIdList.contains(str)); studentIdList.add(str); } }
查看完整描述

1 回答

已采納
?
慕粉4075985

TA貢獻104條經驗 獲得超33個贊

str是局部變量,你要把它寫到外面去

查看完整回答
反對 回復 2017-04-10
  • 1 回答
  • 0 關注
  • 4469 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號