I'm trying to build an ArrayList of objects in runtime inside a method with a specific name:
public void createNewArray(String arrayName){
ArrayList <StoreItem> arrayName = new ArrayList<StoreItem>();
}
The reason I'm trying is because, I don't know how many ArrayLists I will need to create.
What I'm trying to do is to pass a string parameter to the function (createNewArray
) and then use this parameter as the ArrayList name.
Can I do such thing in Java?