public class RandomTest { public static void main(String[] args) { int max=50; int min=1; int[] ra = new int[50]; Random random = new Random(); for (int i=0; i<50; i++) { int s = random.nextInt(max)%(max-min+1) + min; ra[i]=s; System.out.println(s); } } }
int b[] = new int [50]; Scanner s = new Scanner(System.in); try { for(int i = 0; s.hasNextInt(); ++i) b[i] = s.nextInt(); } catch(ArrayIndexOutOfBoundsException e) {System.out.print("数组越界! "); }追问