package
method;
import
javax.swing.
*
;
//
随机数

public
class
RandomIntegers
...
{
public static void main(String args[])...{
int value;
String output="";

for(int i=1;i<=20;i++)...{
value = 1 + (int) (Math.random() * 6);
output += value + " ";
if(i % 5 == 0)
output +=" ";
}
JOptionPane.showMessageDialog(null, output,"20Random Numbers from 1 to 6",JOptionPane.INFORMATION_MESSAGE);
}
}
生成1-6随机数示例

5162

被折叠的 条评论
为什么被折叠?



