Suppose I have a method that returns a list of String names.
public List<String> buildNamesList(){
List<String> namesList = new List<String>();
//add several names to the list
return namesList;
}
Now if I have a method that needs that namesList would returning it like so be the best way?
public void someMethod(){
List<String> namesList = new List<String>();
namesList = buildNamesList();
//traverse namesList
}
If you are creating a new list in your buildNamesList method, I would just say: