產生一個1~n的隨機變數 方法:num1= (int)(Math.random()*n)+1; 範例:產生一個1~6 的隨機變數 int num1; num1= (int)(Math.random()*6)+1;