本段代码是生成的六位随机数.也可修改生成任意位随机数. int[] array = {0,1,2,3,4,5,6,7,8,9}; Random rand = new Random(); for (int i = 10; i > 1; i--) { int index = rand.nextInt(i); int tmp = array[index]; array[index] = array[i - 1]; array[i - 1] = tmp; } int re…
package lianxi; import java.util.Random; public class suijishu { public static void main(String[] args) { Random random = new Random(); int[] arr = new int[4]; arr[0] = random.nextInt(9); int i = 1; //外循环定义四个数 while(i <=3) { int x = random.nextInt(9)…
java生成指定范围的随机数 package edu.sjtu.erplab.io; import java.util.Random; public class RandomTest { public static void main(String[] args) { int max=20; int min=10; Random random = new Random(); int s = random.nextInt(max)%(max-min+1) + min; System.out.pri…