I have an ArrayList of ArrayLists of words where Word is a class.
ArrayList<ArrayList<Word>> arrayColumns = new ArrayList();
with every new column I have to create a new ArrayList of Words and then add that to arrayColumns.
This ArrayList I am creating dynamically and want to name it as arrayWordColumn1, arrayWordColumn2 etc with the addition of every new column. As I don't know how many columns will be there I am trying to write a method to create an ArrayList. Something Like :
public ArrayList<OCRWord> createColumn (count){
ArrayList<OCRWord> arrayWordColumn+count = new ArrayList();
return ArrayList;
}
How can I create arrayLists in such a manner so that if count is 1,2,3,4... it should create ArrayLists with names arrayWordColumn1, arrayWordColumn2, arrayWordColumn3 etc.?
In Short the name arrayWordColumn1 should be formed by concatenating two things --> arrayWordColumn + count where count will be 1,2,3,4...
Map<String,List<Word>>, which i think gets as close as possible to what you would like to have as "variable" name, where thekeyof the map would represent your "variable" name.List<List<Word>> arrayColumns = new ArrayList<>();