Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to program a plastic array with the length of 10 to fill the random number of 0~ 100 and print it out?
How to program a plastic array with the length of 10 to fill the random number of 0~ 100 and print it out?
Import java.util.*

And if you write like this, the output result should be the same, right?

You don't have setSeed.

Random statements are best placed outside the loop.

And nextint, not nextInt, pay attention to capitalization.

Finally, it is more convenient to use Math.random ().

I write both methods.

Import java.util. *;

Common class randomness {

Public static void main(String[] args) {

int[]array = new int[ 10];

//Random Random = new Random(new Date()。 getTime());

for(int I = 0; I < array. Length; i++){

array[I]=(int)(math . random()* 100); /* This function generates double-precision data between 0 and 1, * 100, which is equivalent to the number of 0- 100 */

//array[I]= random . nextint( 100);

}

for(int I = 0; I < array. Length; i++){

system . out . println(array[I]);

}

}

}

PS: You can also use the two lines of comments.