i want to create a class that has a constructor to create an arraylist. then i want to create another MAIN class that will create new arraylist objects. how can i do this?
i tried something but i'm getting compile errors.
for instance i wanted to create a class like this
my main class
but the problem here is, i want the contructor to create an array list that will take an argument of how the Arraylist<String> is to be named.
i know this is simple, but i forgot how to do this somehow. please help me out
Emanuel Mensa wrote:ok i want to create a contructor that will take as a parameter a name for an arraylist. now i made it simpler.
Okay, but what do you mean a "name for an ArrrayList"? Objects don't have names, so are you defining some class that will contain an ArrayList field and a name field, so that you can associate that name with that list?
Or perhaps you're thinking of passing in a variable that refers to an ArrayList? Note that a variable is not an object's name. Objects don't have names.