generate a random lowercase letter

  • Thread starter twink via JavaKB.com
  • Start date
T

twink via JavaKB.com

How can i generate a random lowercase letter? And also how can I convert a
String to int?
 
A

Andrew Thompson

How can i generate a random lowercase letter? And also how can I convert a
String to int?

This is not a help desk.
<http://www.physci.org/codes/javafaq.jsp#homework>

Such beginner questions are better answered at..
<http://www.physci.org/codes/javafaq.jsp#cljh>

And if you are really having difficulty knowing where
to start, check here..
<http://www.physci.org/codes/javafaq.jsp#start>
...as Patricia Shanahan has just the advice you need.

Since you are probably under some misapprehensions about
the Usenet Newsgroup to which you are posting..
<http://www.physci.org/codes/javafaq.jsp#usenet>

In fact, you would benefit from reading the entire FAQ.
 
J

Joan

Sergey B via JavaKB.com said:
You can generate random integer between 0 and 23 and convert it
to the
corresponding lowercase letter.

I think you mean 25 unless you are trying to point out something
about
different character sets in different countries.

char x = "abcdefghijklmnopqrstuvwxyz".charAt(ran);

The above statement works, but I will let you figure out
for yourself how to generate a random number.
 
S

Sergey B via JavaKB.com

Yes you are right of course. The random number must be from 0 to 25.
 
S

Sergey B via JavaKB.com

I was actually trying to convert the String into its corresponding Int value,
say from "a" to 72

You can simply cast it to a short integer.

short charIndex = (short)myCharacter;
 
K

Kerry Soileau

Rubbish, you have no authority here.


Andrew Thompson said:
This is not a help desk.
<http://www.physci.org/codes/javafaq.jsp#homework>

Such beginner questions are better answered at..
<http://www.physci.org/codes/javafaq.jsp#cljh>

And if you are really having difficulty knowing where
to start, check here..
<http://www.physci.org/codes/javafaq.jsp#start>
..as Patricia Shanahan has just the advice you need.

Since you are probably under some misapprehensions about
the Usenet Newsgroup to which you are posting..
<http://www.physci.org/codes/javafaq.jsp#usenet>

In fact, you would benefit from reading the entire FAQ.
 
T

Tris Orendorff

Sergey B via JavaKB.com said:
You can generate random integer between 0 and 23 and convert it to the
corresponding lowercase letter.

Ahem! As the founding member of the "Don't Forget About 'y' and 'z' at the End of the Alphabet" society I must
formally lodge a complaint. Just a reminder that the next meeting is to be held at the:

General Assembly Hall
UN Headquarters,
New York, NY
14-September-2005
19:00-21:30.

--

Sincerely,

Tris Orendorff
[Two antennae meet on a roof, fall in love and get married. The ceremony wasn't much, but the reception
was excellent.]
 
S

steve


The same place that , the answer to the universe and everything is 49

but that said it's seems his question is not at all related to what he
initially wants.

How can i generate a random lowercase letter?

I was actually trying to convert the String into its corresponding Int
value, say from "a" to 72

the 2 questions are totally unrelated, but you can bet he will have question
3.
 
A

anal_aviator

Rubbish, you have no authority here.


Andrew Thompson said:
This is not a help desk.
<http://www.physci.org/codes/javafaq.jsp#homework>

Such beginner questions are better answered at..
<http://www.physci.org/codes/javafaq.jsp#cljh>

And if you are really having difficulty knowing where
to start, check here..
<http://www.physci.org/codes/javafaq.jsp#start>
..as Patricia Shanahan has just the advice you need.

Since you are probably under some misapprehensions about
the Usenet Newsgroup to which you are posting..
<http://www.physci.org/codes/javafaq.jsp#usenet>

In fact, you would benefit from reading the entire FAQ.

tell you what "Kerry", for the next month you can answer every lame newbie
question posted , without ever complaining.
Including the ones :
1.can you do my homework for me.
2. can you teach me java without me actually doing any work.

otherwise STFU.
 
T

Thomas Hawtin

Tris said:
Ahem! As the founding member of the "Don't Forget About 'y' and 'z' at the End of the Alphabet" society I must
formally lodge a complaint. Just a reminder that the next meeting is to be held at the:

You are assuming the locale is not set to greek or something weird and
foreign.

Tom Hawtin
 
R

Raymond DeCampo

Thomas said:
You are assuming the locale is not set to greek or something weird and
foreign.

Tom Hawtin

I think we should file a RFE with Sun to get
Locale.getNumberOfLowercaseLetters() added.

Ray
 
J

Joan

Raymond DeCampo said:
Is this a joke? Or do you really think that the code you
posted is better than that you quoted?

Ray

If you mean "short charIndex = (short)myCharacter;"
it does not meet the requirements.
The OP says for "string" not "char"
If you put myString for myCharacter, it doesn't compile.
 
R

Raymond DeCampo

Joan said:
If you mean "short charIndex = (short)myCharacter;"
it does not meet the requirements.
The OP says for "string" not "char"
If you put myString for myCharacter, it doesn't compile.

OK, I misunderstood. I think it would have been clearer if you used a
variable to represent the String in your example, because as it stands,
it looks ridiculous.

Ray
 
J

Joan

Raymond DeCampo said:
OK, I misunderstood. I think it would have been clearer if you
used a variable to represent the String in your example,
because as it stands, it looks ridiculous.

Ray

I agree that it looks strange the first time you see it. It is
mostly
to get people to think about "is it possible to use a string like
that?"
 
A

Andrew Thompson

I think we should file a RFE with Sun to get
Locale.getNumberOfLowercaseLetters() added.

Nah! Be more definitive.

/** Ignores those last 'funny looking' letters in any language. */
Locale.setNumberOfLowercaseLetters(int num)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top