I'm trying to create a new HashMap for each document I have as input. In pseudeocode I can think of something like:
For(eachInputDoc)
{
Map<String, String> mapInputNumber = new HashMap<String, String>;
}
So that for 4 documents you would have:
mapInput1
mapInput2
mapInput3
mapInput4
How can I accomplish this?
It looks like you're trying to declare variables dynamically. You can't do that in Java - the variables themselves are determined at compile time. However, you could create a list:
List<Map<String, String>> maps = new ArrayList<Map<String, String>>();
for (Document doc : docs)
{
Map<String, String> map = new HashMap<String, String>();
// Populate map from doc
maps.add(map);
}
I suggest you make an ArrayList of HashMaps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With