Namespaces
Variants
Actions

How to get a random number from range

Jump to: navigation, search

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

SignpostIcon Gear 52.png
Article Metadata

Compatibility
Platform(s): Java ME

Article
Created: firt (15 Apr 2007)
Last edited: lpvalente (18 Mar 2012)
public int getRandomNumber(int min, int max) {
Random rnd;
rnd = new Random();
return min + rnd.nextInt(max - min);
}
This page was last modified on 18 March 2012, at 03:11.
118 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved