Appending variable values to filename/variable names in Java/c++

Discussion in 'Software' started by Sasquat, Jan 12, 2006.

  1. Sasquat

    Sasquat Private E-2

    I was wondering if anyone could help me with a programming matter?

    Basically, I am trying to create n ArrayLists in Java, which I would like to
    include the construction for this within loops with an appropriate name. So I
    will find what n is from a calculation and I will be using an ArrayList as I
    will not know the size of the vectors until all calculations have been
    performed.

    To save me hard coding in the construction of such ArrayLists when I know the
    number (n) that I will need I have been racking my brains to come up with a
    neater solution. In the past I have seen someone using notation such as a % or
    $ or something like this in c++ which can be used to append the value of a variable to
    the end of a filename, or at least I think that was what it was doing. What I am
    wondering is there any such way in Java to loop over n and appropriately name my
    ArrayLists as name1, name2.....namen? Also, I think that I would need to access
    them using a similar method.

    Regards
    Sarah
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds