Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to get a random number from range

From Wiki
Jump to: navigation, search

This Java ME code snippet shows how to return a random number between a specified maximum and minimum value.

Article Metadata
Article
Created: firt (15 Apr 2007)
Last edited: hamishwillee (22 Jul 2013)
public int getRandomNumber(int min, int max) {
Random rnd;
rnd = new Random();
return min + rnd.nextInt(max - min);
}
This page was last modified on 22 July 2013, at 23:44.
207 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×