Results 1 to 4 of 4
  1. #1
    Prime624 is offline Member
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    96
    Rep Power
    0

    Default String to Variable Name?

    I'm doing a for loop and I need to do the same few lines of code for each (JButton) variable. I named them q1-o9 (qwertyuio) (123456789). I just need to know how to turn a String into a valid variable name. Is there an easy way to do this or should I do something totally different?

    NEVERMIND
    Last edited by Prime624; 02-08-2013 at 07:08 AM.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: String to Variable Name?

    You should do something totally different. Like using arrays or Lists.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Prime624 is offline Member
    Join Date
    Feb 2013
    Location
    San Diego
    Posts
    96
    Rep Power
    0

    Default Re: String to Variable Name?

    K thanks. Just read an intro for arrays and I now feel stupid for posting this.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default Re: String to Variable Name?

    Nothing stupid about it. We all had to learn to use arrays.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Use the value of a string as a variable/atribute
    By Kmsitu_bcn in forum New To Java
    Replies: 6
    Last Post: 12-01-2011, 05:34 PM
  2. String variable problem
    By gkoef in forum New To Java
    Replies: 4
    Last Post: 12-05-2010, 02:15 PM
  3. Convert variable name to string.
    By MHardeman25 in forum New To Java
    Replies: 9
    Last Post: 08-17-2010, 09:18 PM
  4. Replies: 1
    Last Post: 08-03-2007, 10:52 AM
  5. String Variable
    By Eric in forum Advanced Java
    Replies: 1
    Last Post: 06-06-2007, 04:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •