Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
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:
Beginning Java
Randomly generate a string of number?
Nico Yukiko
Greenhorn
Posts: 21
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
how to generate a six digit number?
Steve Morrow
Ranch Hand
Posts: 657
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
static String oneWay() { java.util.Random rand = new java.util.Random(); StringBuilder buf = new StringBuilder(); for (int i = 0; i < 6; i++) { buf.append(rand.nextInt(10)); } return buf.toString(); } static String anotherWay() { java.util.Random rand = new java.util.Random(); int result = rand.nextInt(1000000); return String.format("%1$06d", result); } // I'm sure there are plenty others...
Nico Yukiko
Greenhorn
Posts: 21
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
but how can i call it in the
servlet
??
if this is in the same class as the servlet
Michael Ernest
High Plains Drifter
Posts: 7289
I like...
posted 18 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Have the appropriate service method (doGet() or doPost(), for example) call the the random-number generating method; that's all there is to it.
Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Legend has it that if you rub the right tiny ad, a genie comes out.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Java with curl (http://curl.haxx.se/)
Arrays
How to generate a random hour?
MySql Random Alphanumeric number
sankar
More...