Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Loop through variable names

darkmatterMay 24 2012 — edited May 24 2012
I have variable names like user1, user2, user3,... along with other variable names using numbers in the actual name. I was wondering if there was a way for me to use a for loop to reference those variable names using the for loop counter as an index like...

for (int i=0; i < 10; i++) {

user[i] = "some data";

}

Obviously, the above doesn't work but is there any way to force an evaluation of the value of i before evaluating user, if that makes any sense? Any help is appreciated.

Edited by: darkmatter on May 24, 2012 7:18 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 21 2012
Added on May 24 2012
7 comments
1,191 views