Several ways in which Java generates random numbers

Source: Internet
Author: User

Tag: The current time object produces the same number of time methods as float itself list

One, Math.randam () method

Generates a random number of type 0-1 for a double, *100 the number to get the number you want.

Second, Randam class object

A random class is provided in the Java.util package, and we can create a randomly generated object that produces random numbers, randomly float, double,long.

① method of non-seed

The number of milliseconds to return without a seed is the current time, with duplicate numbers.

② with Seeds

With the same seed will produce the same number list

Several ways in which Java generates random numbers

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.