I'll echo what Jim has said in the comments. Being resourceful is an important skill as a software developer. A Google search would have quickly turned up a helpful article like this one.
You need to use the Random
class to accomplish this.
Random randomGenerator = new Random();
int array = new int[100];
for (int idx = 0; idx < 100; ++idx){
array[idx] = randomGenerator.nextInt(100) + 1;
}
Note on the usage of the nextInt(int n) method:
It produces a pseudo-random integer between 0 (inclusive) and the specified integer (exclusive). That is the reason for adding 1
to the output of nextInt(100)
as it shifts your output range from 0-99
to 1-100
as desired.