This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
How do i create random strings?
Andrew Stevens
Greenhorn
Joined: May 29, 2001
Posts: 3
posted
May 29, 2001 13:31:00
0
I need a no paramater constructor that generates a random 4 letter
string
. Is there a way to do this using Math.random?
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4118
2
I like...
posted
May 29, 2001 13:41:00
0
char randomLetter = (char)('A' + (Math.random() * 26));
I'm leaving the rest for you to figure out just in case this is a school assignment
Junilu
Junilu - [
How to Ask Questions
] [
How to Answer Questions
] [
MiH
]
Siobhan Murphy
Ranch Hand
Joined: Oct 19, 2000
Posts: 72
posted
May 30, 2001 06:46:00
0
You could create a collection of the 26 characters, shuffle the Collection and select four elements.
Best wishes
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: How do i create random strings?
Similar Threads
Random Number Chooser programming exercise
Please Help
Simple Question
Help with random class
WA #1.....word association
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter