主要是Random的使用
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("数组越界! ");
}
String a[] = new String[50];
for(int i = 0; i < 50; i++){
a[i] = (int)(Math.random()*50);
}