Categories: Java | Java ME | How To | Code Examples | Base/System
This page was last modified 09:38, 28 November 2007.
How to get a random number from range
From Forum Nokia Wiki
If you need to get a random number between X and Y, you should use some mathematical pattern using the Math Class and some calculus.
You can use this quick method to get the random number:
public int getRandomNumber(int min, int max) { Random rnd; rnd = new Random(); return min + Math.abs(rnd.nextInt()) % (max - min); }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SMS reading Problem | mateen_maldar | General Messaging | 3 | 2005-12-30 15:46 |
| Symbian DevCert signed sis + UID protected range | sliponoga | General Symbian C++ | 2 | 2006-06-11 02:32 |
| Unable to install | dee_viz | Symbian Signing, Certification and Security | 6 | 2007-10-16 09:46 |
| Bluetooth range sux! | carl404 | Symbian Networking & Messaging | 5 | 2004-04-19 12:49 |
| Hashtable performance? | Spider@Nokia | Mobile Java General | 1 | 2004-03-24 11:29 |
