Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by Norm View Post
    I wonder what generates means? Could it mean giving a value to a variable?

    The only way I know to "generate" a variable is at source input time. IE when you type in the source
    I think you could use reflection to generate variables at runtime, but that is way past what the OP could understand.
    No, reflection can't do that, one needs ASM to do such things but I won't recommend it to the OP; the OP has a completely incorrect paradigm in his/her head: even if it were possible (which it isn't) to 'generate' a new variable at runtime you can't refer to it because you have to type that in during compile time and therefore declare it before its first use (the compiler enforces that) therefore turning the entire thing in a catch 22. A Map<String, Image> is as close as it goes or just ordinary arrays can solve the OP's problem ...

    kind regards,

    Jos

  2. #22
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default

    > As I understand you cant display multiple image unless each of them has a different variable. So I figured that if I can code the "for" loop to generate a new variable and space it, I can generate multiple pictures.
    What are you going on about? Arrays?
    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    db

  3. #23
    curmudgeon is offline Senior Member
    Join Date
    May 2010
    Posts
    436
    Rep Power
    5

    Default

    Quote Originally Posted by Norm View Post
    I wonder what generates means? Could it mean giving a value to a variable?
    I agree that this is not clear at all which is why I've been trying to get clarification, but first and foremost for what the overall problem is rather than his code solution. My guess is that he wants to do something Java really doesn't do: create new variable names while the program is running, such as variable01, variable02, variable03, ...
    And if so, then he is far better off using an array or List as I suggested, or a Map as Jos suggested.


    The only way I know to "generate" a variable is at source input time. IE when you type in the source
    I think you could use reflection to generate variables at runtime, but that is way past what the OP could understand.
    And likely would force him into a poor program design for his problem. Now if we could only understand the details of the problem, I think we'd be easily able to help him.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Counter
    By ks1615 in forum New To Java
    Replies: 6
    Last Post: 02-20-2009, 03:02 AM
  2. Need helps making counter
    By Lifeis2evil in forum New To Java
    Replies: 3
    Last Post: 11-26-2008, 11:58 PM
  3. Frequency Counter
    By justlearning in forum New To Java
    Replies: 0
    Last Post: 05-07-2008, 10:50 PM
  4. [SOLVED] BST Frequency Counter
    By theonly in forum Advanced Java
    Replies: 7
    Last Post: 04-29-2008, 11:33 PM
  5. Help with static variable counter
    By silvia in forum New To Java
    Replies: 1
    Last Post: 07-19-2007, 07:53 PM

Posting Permissions

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