This paper mainly introduces 3 kinds of methods of obtaining random number in Java, mainly using random () function to realize
Method 1
(data type) (Minimum +math.random () * (maximum-min +1)) Example:
(int) (1+math.random () * (10-1+1))
Random class (Java. util)
The random algorithm implemented in the random class is pseudo-random, that is, random with rules. When a random algorithm is executed, the numbers of the origins of the random algorithm are called seed. A certain number is
Random numbers are often used in actual development work. When a user is created in some systems, a random initialization password is given to the user. This password because it is random, so often only users know. After they have acquired this
Java's Random class, apirandom
In the actual project development process, some random numbers are often required, such as verification numbers during website login, or a certain effect must be achieved at a certain probability, for example, items in
Random Class (Java.util)The random algorithm implemented in the random class is pseudo-random, that is, random with rules. At random, the origin of the random algorithm is called the seed number (seed), the number of seeds on the basis of a certain
The random class is a class that is specifically used to generate a pseudo-random number, which provides two constructors, one with the default seed, and another that requires the programmer to display the seed that passes in a long integer. Unlike
Random Class (Java.util)
The stochastic algorithm implemented in the random class is pseudo random, that is, random with rules. At random, the origin number of the random algorithm is called seed number, and a certain transformation is made on the
Java Random class is located under the Java.util package, mainly used to generate random numbers, this article explains the use of the random class, I hope to help everyoneRandom Class (Java.util)The random algorithm implemented in the random class
From: http://lehsyh.iteye.com/blog/646658
Java generally has two random numbers. One is the random () method in math and the other is the random class.
I. Math. Random ()
Then a decimal number of 0
Instance: how to write, generate a random
Insert several keywords randomly in an article (the number of keywords can be controlled)
Random numbers of random keywords are inserted at random positions in the article.
For example, the limit is to insert 3 keywords. Then the number of keywords
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.