×
Namespaces

Variants
Actions
(Difference between revisions)

How to get a random number from range

From Nokia Developer Wiki
Jump to: navigation, search
lpvalente (Talk | contribs)
m (Lpvalente -)
hamishwillee (Talk | contribs)
m (Hamishwillee - Fix categories)
 
Line 1: Line 1:
[[Category:Java ME]][[Category:How To]][[Category:Code Snippet]][[Category:Base/System]]
+
[[Category:General Programming on Java ME]][[Category:Code Snippet]][[Category:How To]]
 
{{Abstract|This Java ME code snippet shows how to return a random number between a specified maximum and minimum value.}}  
 
{{Abstract|This Java ME code snippet shows how to return a random number between a specified maximum and minimum value.}}  
  
Line 7: Line 7:
 
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
|platform= Java ME
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 
|id= <!-- Article Id (Knowledge base articles only) -->
 
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->

Latest revision as of 02:44, 23 July 2013

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 (23 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 23 July 2013, at 02:44.
203 page views in the last 30 days.
×