作者coilion9670 (白熊)
看板java
標題[問題] 以泛型儲存亂數
時間Sat Jun 16 13:32:57 2012
一道題目以泛型型態儲存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
1F:推 PsMonkey:System.out.print(Math.random()*2) 多跑幾次就知道 06/16 14:02
※ 編輯: coilion9670 來自: 140.128.195.235 (06/16 15:11)