generate a random lowercase letter

Discussion in 'Java' started by twink via JavaKB.com, Aug 6, 2005.

  1. How can i generate a random lowercase letter? And also how can I convert a
    String to int?
    twink via JavaKB.com, Aug 6, 2005
    #1
    1. Advertising

  2. On Sat, 06 Aug 2005 18:13:03 GMT, twink via JavaKB.com wrote:

    > 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.

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    == Proudly Made On Earth ==
    Andrew Thompson, Aug 6, 2005
    #2
    1. Advertising

  3. Sergey B via JavaKB.com, Aug 6, 2005
    #3
  4. twink via JavaKB.com

    Joan Guest

    "Sergey B via JavaKB.com" <> wrote in message
    news:...
    > >How can i generate a random lowercase letter?

    >
    > 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.

    >
    >>And also how can I convert a String to int?

    >
    > http://www.javakb.com/Uwe/Forum.aspx/java-programmer/12886/How-can-I-convert-a-String-to-an-Int
    >
    >
    > twink wrote:
    >>How can i generate a random lowercase letter? And also how can
    >>I convert a
    >>String to int?

    >
    >
    > --
    > Message posted via JavaKB.com
    > http://www.javakb.com/Uwe/Forums.aspx/java-general/200508/1
    Joan, Aug 6, 2005
    #4
  5. Yes you are right of course. The random number must be from 0 to 25.

    Joan wrote:
    >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.



    --
    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200508/1
    Sergey B via JavaKB.com, Aug 6, 2005
    #5
  6. Sergey B wrote:
    >>How can i generate a random lowercase letter?

    >
    >You can generate random integer between 0 and 23 and convert it to the
    >corresponding lowercase letter.
    >
    >>And also how can I convert a String to int?

    >
    >http://www.javakb.com/Uwe/Forum.aspx/java-programmer/12886/How-can-I-convert-a-String-to-an-Int
    >


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

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



    --
    Message posted via JavaKB.com
    http://www.javakb.com/Uwe/Forums.aspx/java-general/200508/1
    twink via JavaKB.com, Aug 7, 2005
    #6
  7. On Sun, 07 Aug 2005 04:08:39 GMT, twink via JavaKB.com wrote:

    > Sergey B wrote:
    >>>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


    Where does '72' come from?
    <http://www.physci.org/codes/char.jsp?char=97>
    <http://www.physci.org/codes/char.jsp?char=65>

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    This Episode Performed Entirely By Sock Puppets
    Andrew Thompson, Aug 7, 2005
    #7
  8. >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;


    --
    Message posted via http://www.javakb.com
    Sergey B via JavaKB.com, Aug 7, 2005
    #8
  9. twink via JavaKB.com

    Joan Guest

    "Sergey B via JavaKB.com" <> wrote in message
    news:...
    > >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;
    >

    or
    int i = "a".charAt(0)
    Joan, Aug 7, 2005
    #9
  10. Rubbish, you have no authority here.


    "Andrew Thompson" <> wrote in message
    news:jx5vvepfmmwo$...
    > On Sat, 06 Aug 2005 18:13:03 GMT, twink via JavaKB.com wrote:
    >
    >> 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.
    >
    > --
    > Andrew Thompson
    > physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    > == Proudly Made On Earth ==
    Kerry Soileau, Aug 7, 2005
    #10
  11. "Sergey B via JavaKB.com" <> wrote in news::

    >>How can i generate a random lowercase letter?

    >
    > 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.]
    Tris Orendorff, Aug 8, 2005
    #11
  12. twink via JavaKB.com

    steve Guest

    On Sun, 7 Aug 2005 13:01:22 +0800, Andrew Thompson wrote
    (in article <jzj9j067almg.1x28jbubv6cxe$>):

    > On Sun, 07 Aug 2005 04:08:39 GMT, twink via JavaKB.com wrote:
    >
    >> Sergey B wrote:
    >>>> 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

    >
    > Where does '72' come from?
    > <http://www.physci.org/codes/char.jsp?char=97>
    > <http://www.physci.org/codes/char.jsp?char=65>
    >
    >


    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.
    steve, Aug 8, 2005
    #12
  13. twink via JavaKB.com

    anal_aviator Guest

    On Mon, 8 Aug 2005 05:29:39 +0800, Kerry Soileau wrote
    (in article <73vJe.108505$>):

    > Rubbish, you have no authority here.
    >
    >
    > "Andrew Thompson" <> wrote in message
    > news:jx5vvepfmmwo$...
    >> On Sat, 06 Aug 2005 18:13:03 GMT, twink via JavaKB.com wrote:
    >>
    >>> 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.
    >>
    >> --
    >> Andrew Thompson
    >> physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    >> == Proudly Made On Earth ==

    >
    >


    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.
    anal_aviator, Aug 8, 2005
    #13
  14. Tris Orendorff wrote:
    > "Sergey B via JavaKB.com" <> wrote in news::
    >
    >>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:


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

    Tom Hawtin
    --
    Unemployed English Java programmer
    http://jroller.com/page/tackline/
    Thomas Hawtin, Aug 8, 2005
    #14
  15. Joan wrote:
    >
    > "Sergey B via JavaKB.com" <> wrote in message
    > news:...
    >
    >> >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;
    >>

    > or
    > int i = "a".charAt(0)


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

    Ray

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Aug 8, 2005
    #15
  16. Thomas Hawtin wrote:
    > Tris Orendorff wrote:
    >
    >> "Sergey B via JavaKB.com" <> wrote in
    >> news::
    >>
    >>> 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:

    >
    >
    > 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

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Aug 8, 2005
    #16
  17. twink via JavaKB.com

    Joan Guest

    "Raymond DeCampo" <> wrote in message
    news:M9yJe.3701$...
    > Joan wrote:
    >>
    >> "Sergey B via JavaKB.com" <> wrote in message
    >> news:...
    >>
    >>> >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;
    >>>

    >> or
    >> int i = "a".charAt(0)

    >
    > 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.
    Joan, Aug 8, 2005
    #17
  18. Joan wrote:
    >
    > "Raymond DeCampo" <> wrote in message
    > news:M9yJe.3701$...
    >
    >> Joan wrote:
    >>
    >>>
    >>> "Sergey B via JavaKB.com" <> wrote in message
    >>> news:...
    >>>
    >>>> >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;
    >>>>
    >>> or
    >>> int i = "a".charAt(0)

    >>
    >>
    >> 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.


    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

    --
    XML is the programmer's duct tape.
    Raymond DeCampo, Aug 8, 2005
    #18
  19. twink via JavaKB.com

    Joan Guest

    "Raymond DeCampo" <> wrote in message
    news:NHzJe.5807$...
    > Joan wrote:
    >>
    >> "Raymond DeCampo" <> wrote in message
    >> news:M9yJe.3701$...
    >>
    >>> Joan wrote:
    >>>
    >>>>
    >>>> "Sergey B via JavaKB.com" <> wrote in
    >>>> message news:...
    >>>>
    >>>>> >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;
    >>>>>
    >>>> or
    >>>> int i = "a".charAt(0)
    >>>
    >>>
    >>> 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.

    >
    > 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?"
    Joan, Aug 8, 2005
    #19
  20. On Mon, 08 Aug 2005 01:02:54 GMT, Raymond DeCampo wrote:

    > 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)

    --
    Andrew Thompson
    physci.org 1point1c.org javasaver.com lensescapes.com athompson.info
    Not Affiliated With Futurama Brass Knuckle Co.
    Andrew Thompson, Aug 8, 2005
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vertigo

    big letter -> small letter

    vertigo, Jul 6, 2004, in forum: Python
    Replies:
    4
    Views:
    750
    Reinhold Birkenfeld
    Jul 6, 2004
  2. Tony Meyer

    RE: big letter -> small letter

    Tony Meyer, Jul 6, 2004, in forum: Python
    Replies:
    0
    Views:
    502
    Tony Meyer
    Jul 6, 2004
  3. Andrew McNamara

    Re: big letter -> small letter

    Andrew McNamara, Jul 6, 2004, in forum: Python
    Replies:
    2
    Views:
    749
    Scott David Daniels
    Jul 6, 2004
  4. globalrev
    Replies:
    4
    Views:
    753
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,156
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page