|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttips.random.RandomValues
RandomValues Sample class that demonstrates how to generate a random number between two values.
| Field Summary | |
private java.util.Random |
m_Random
|
| Constructor Summary | |
(package private) |
RandomValues()
Create the object - and create the random number generator java.util.Random |
| Method Summary | |
static void |
main(java.lang.String[] args)
Run this to demonstrate the algorithm is working... |
int |
next(int nLower,
int nUpper)
Get hold of a random number between the values of nLower and nUpper. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private java.util.Random m_Random
| Constructor Detail |
RandomValues()
| Method Detail |
public static void main(java.lang.String[] args)
First create an object and then loop 1000 times returning a random number between 2 values. If that number is outside the range then report the error
args - There are no input arguments
public int next(int nLower,
int nUpper)
throws java.lang.Exception
nUpper - The upper of limitnLower - The lower limit
java.lang.Exception - when the input params are incorrect or the random number generator fails.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||