import java.util.Random;
class Main {
public static void main(String[] args) {
// create array
int data[][] = new int[5][20];
// loop over array
for (int i = 0; i < 5; ++i) {
// assign random value (in range 2005..2018)
// for first element of subarray
data[i][0] = random(2005, 2018);
// loop over subarray starting from second element
// and assign random value (in range 1..100)
for (int j = 1; j < 20; ++j) {
data[i][j] = random(1, 100);
}
}
}
// get random integer in range min..max
public static int random(int min, int max) {
Random rnd = new Random();
return min + rnd.nextInt(max - min + 1);
}
}
Comments
Leave a comment