Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java Micro Edition
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java Micro Edition
generating random numbers
Jude Fawly
Ranch Hand
Posts: 33
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
hi there,
how can i generate a random number between specific range, say for example between 1-5??
Teach me to die that so I may<br />Rise glorious at the awful day
Yuri Magrisso
Ranch Hand
Posts: 58
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You can use java.util.Random:
Random rGen = new Random(); int r = rGen.nextInt(); r = 1 + r % 4; // where 1 is the start of your interval // and 4 is the end of the interval minus the start (5-1)
Yuri
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
generating unique numbers
how to genrate a random number inside the range
Random numbers
Random number between size of an array
Regarding random number generation.
More...