/*
* Random: A class that generates random numbers
*
* Construction Method:
* Public Random (): No seed, with default seed, is the millisecond value of the current time
*public Random (Long Seed): gives the specified seed
*
* Once the seed is given, the random number obtained is the same each time.
*
* Member Method:
* public int Nextint (): Returns a random number in the range of int
*public int nextint (int n): Returns the inner random number of the [0,n] range
*/
Example:
Defining pseudo-random numbers
Random ran = new random ();
Construction method
Public Pane () {
SetBackground (Color.Black);//Set Background color
for (int i=0;i<starnum;i++)
{
X[i]=ran.nextint (Star.dd.width);
Y[i]=ran.nextint (Star.dd.width);
}
}
int size = Ran.nextint (50); The maximum value is 50
The first thing to say is, what is called pseudo-random number. The computer does not produce an absolute random number, and the computer can only produce "pseudo-random numbers".
In fact, an absolute random number is only an ideal random number, and even if the computer develops, it will not produce a random number of absolute random numbers.
。 A computer can only generate a relative random number, or pseudo-random number. Pseudo-random number is not a pseudo-random number, where the "pseudo" is a regular meaning,
The pseudo-random numbers generated by computers are both random and regular.
Java pseudo-Random number class