The above Class in the method setLocationCells() assigns the string value loc without creating a ArrayList object or using the add method, In this scenario what happens?Is this like declaring a array variable and assigning values?
No, it is nothing like creating an array and assigning a member at all. You are not assigning the String value loc because loc isn't a String.
The field loc is an ArrayList<String> so you have to create an ArrayList<String> reference somewhere else and put that reference to an ArrayList<String> into that set method and into the loc reference. The ArrayList<String> will contain as many or as few Strings as were put into it "somewhere else," but you could of course change that after it is passed.
Joined: Jan 15, 2007
Do you mean that a ArrayList<String> object should be created somewhere else, assign values or strings to it, pass it to setLocations method. this will result in locationCells pointing to a ArrayList String type Object?