Home > Back-end >  8, JAVA simple application of random number
8, JAVA simple application of random number

Time:09-20

Public class test04 {
Public void test01 () {
//random number: Math. The random ()
Double num1=Math. The random ();//the scope of the initial random number is [0, 1), is the decimal, all defined type double
System. The out. Println (num1);
//four random integer
//(Math. The random () * 9000) integer value range is: [0900 0)
//((Math. The random () * 9000) + 1000) integer value range is: [1000100 00)
//((Math. The random () * 9000) + 1000) is a decimal value of the range, so be converted to an integer
Int num2=(int) ((Math. The random () * 9000) + 1000);
System. The out. Println (num2);
}
Public static void main (String [] args) {
Test04 test=new test04 ();
Test. Test01 ();