1.在j2se中使用Math.random()(产生0-1之间的double)方法:
如
public void numCreate(){ int array[] = new int[10]; for(int i=0;i<10;i++){ array[i]=(int)(Math.random()*100); for(int j=0;j2.使用Random对象产生随机数,他可以产生随机的整数和浮点数。利用Random实例的next..()方法。一般情况选择不带种子的方式生成随机数。如
public void numCreate(){ int array[] = new int[10]; for(int i=0;i<10;i++){ Random r = new Random(); array[i] = r.nextInt(100); for(int j=0;j其中nextInt方法中的参数可以设置产生数字的范围。在0(包括)和指定值(不包括)之间 。











