- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.Random Class
Introduction
The java.util.Random class instance is used to generate a stream of pseudorandom numbers.Following are the important points about Random −
The class uses a 48-bit seed, which is modified using a pnear congruential formula.
The algorithms implemented by class Random use a protected utipty method that on each invocation can supply up to 32 pseudorandomly generated bits.
Class declaration
Following is the declaration for java.util.Random class −
pubpc class Random extends Object implements Seriapzable
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | Random() This creates a new random number generator. |
2 | Random(long seed) This creates a new random number generator using a single long seed. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method generates the next pseudorandom number. |
2 | This method returns the next pseudorandom, uniformly distributed boolean value from this random number generator s sequence. |
3 | This method generates random bytes and places them into a user-suppped byte array. |
4 | This method returns the next pseudorandom, uniformly distributed double value between 0.0 and 1.0 from this random number generator s sequence. |
5 | This method returns the next pseudorandom, uniformly distributed float value between 0.0 and 1.0 from this random number generator s sequence. |
6 | This method returns the next pseudorandom, Gaussian ("normally") distributed double value with mean 0.0 and standard deviation 1.0 from this random number generator s sequence. |
7 | This method returns the next pseudorandom, uniformly distributed int value from this random number generator s sequence. |
8 | This method returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator s sequence. |
9 | This method returns the next pseudorandom, uniformly distributed long value from this random number generator s sequence. |
10 | This method sets the seed of this random number generator using a single long seed. |
Methods inherited
This class inherits methods from the following classes −
java.util.Object