Java pseudo-Random number class

Source: Internet
Author: User

/*
* 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.