Random () function parsing in Java

Source: Internet
Author: User

The use of random numbers is sometimes encountered in software development (some codes are random numbers generated by random). Previously only know how to use, have never thought about the principle of random. A few days ago remember to go online to check this problem, today just have time, from the Internet to access some information.


Java contains two types of random, one is java.util.Random, the use of pseudo-random (random), the same number of random objects, the same number of times generated by the number is exactly the same. This random class includes two constructors, public random (), and public random (long Seed). The stochastic methods of this class are more, including Nextboolean (), Nextint, nextdouble () and so on.


The other is that the random,math.random under math generates a [0,1.0 interval of decimals] (which is actually called Java.util.random China's Nextdouble () method)

Random () function parsing in Java

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.