[問題] 以泛型儲存亂數

看板java作者 (白熊)時間13年前 (2012/06/16 13:33), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串1/1
一道題目以泛型型態儲存5個小於50的亂數 TreeSer<Integer> ts = new TreeSet<Integer>(); for(int i=0; i<5; i++){ ts.add((int)(Math.random()*50+1)); } 其中最後的 +1 是為了甚麼 煩請指教 http://ideone.com/0uJU9 編譯失敗是為甚麼@@ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.128.195.235

06/16 14:02, , 1F
System.out.print(Math.random()*2) 多跑幾次就知道
06/16 14:02, 1F
※ 編輯: coilion9670 來自: 140.128.195.235 (06/16 15:11)
文章代碼(AID): #1Ft1gCpn (java)