This Java ME code snippet shows how to return a random number between a specified maximum and minimum value.
Article Metadata
Compatibility
Platform(s): Java ME
Article
Created:
firt
(15 Apr 2007)
public int getRandomNumber(int min, int max) {
Random rnd;
rnd = new Random();
return min + rnd.nextInt(max - min);
}
23 Sep
2009
This article shows how you can get random number from a range between two numbers.
For that author demonstrates a method getRandomNumber() that returns a random number in between min to max number.To get Random number , an instance of Random is created.
Explained with good calculation.
24 Sep
2009
Article shows how to get a random number form a pool of min and max. nextInt() is the main theme in whole article. In many real time application there is a need of creating random numbers as a part of the application. This article may help at that time. As code says everything but putting image which shows diff number at time interval is a good improvement.