Home > Back-end >  Randomly generated within 20 10 integer greater than or equal to 0, and display it
Randomly generated within 20 10 integer greater than or equal to 0, and display it

Time:10-12

CodePudding user response:

The
refer to the original poster m0_46331268 response:


Math. The random randomly generated [0, 1) int, take 10 after cycle 20 times

CodePudding user response:

In Java. The util package below there is a kind of Random, instantiate objects of the Random class

The Random Random=new Random ();

The random nextInt (10);//generated is an integer greater than or equal to zero and less than 10

CodePudding user response:

refer to the second floor weixin_41900958 response:
in Java. The util package below there is a kind of Random, instantiate objects of the Random class

The Random Random=new Random ();

The random nextInt (10);//is greater than or equal to zero and less than 10 integers

To process, thank you

CodePudding user response:

reference m0_46331268 reply: 3/f
Quote: refer to the second floor weixin_41900958 response:
in Java. The util package below there is a kind of Random, instantiate objects of the Random)

The Random Random=new Random ();

The random nextInt (10);//is greater than or equal to zero and less than 10 integers

You can to process thank you


Process? To a loop statement not to be good again?
The building Lord, learning programming must be diligent, otherwise don't learn!

CodePudding user response:

 
import java.util.Random;

Public class T {

Public static void main (String [] args) {
int i=0;
Do {
System. The out. Println (" first "+ (I + 1) +" is a Random number is: "+ new Random () nextInt (10));
i++;
} while (i<20);
}
}
  • Related