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!

Is there a way to set a java variable name dynamically?

forumKid2Jun 24 2010 — edited Jun 24 2010
Let's say I have a string which holds a variable name as such:
String myList = "arrayList1";
Is there a way to create an ArrayList for example with that name, kind of like this
ArrayList<String> "myList" = new ArrayList<String>;
The variable name is not known until runtime, thats my problem. I'm building a few result sets from an xml file and putting them into arraylists, then a routine to read from the arraylists. So my problem is how to be able to reference those arraylists.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 22 2010
Added on Jun 24 2010
4 comments
1,013 views