I think it can be explained better with example:
I have arrayLists by names sname,stime,snumber,etc., each carrying different values
and a dynamic string 'dString' that is a concatenation of "s" and a variable VR that carries (name, time, number, etc.).
Bbased on the value of VR i get from a loop, i'd like to use respective arraylist in a method. How can i use dString to refer to respective arraylist?
ArrayList<String> sname = new ArrayList<>();
ArrayList<String> stime= new ArrayList<>();
ArrayList<String> snumber = new ArrayList<>();
String[] VR = {"name","time","number"};
for(String str:VR) {
String dString = "s"+str;
String temp= dString.get(2); //How to get this?
}
(This is just as an example. the arraylists aren't empty. it's a long program so i haven't included it).
Map(key-value store) instead. You cannot access local variables by name dynamically.