posted 18 years ago
This "how do I determine the variable name" thing is a fundamental milestone that all thinking programmers get to -- some earlier, some later. The fact that you see the problem, and are trying to find a solution, is a good sign!
In any case, the important thing is that there is no solution, at least not the kind you're looking for. You can't invent variables at runtime. The compiler has to know the name of a variable, which means you have to know the name while you're typing the program -- and since you don't, for example, know how many files will be read, you don't know the names.
Now, the good news is that all it takes is looking at the problem from a slightly different angle, and I think when I say this you will slap your forehead at its obviousness: the solution to the "how do I make up variable names at runtime" question is always "use a Collection." Use, in your case, a List of Maps -- or perhaps a Map of Maps, with the filenames as keys and the word maps as the values. Then each Map has a "name" in the form of its key in the map.