If I have a list that I pass into a method to be populated, can I then reference that list variable in the class/method that did the passing, without having to return the list?
Here's an example, where a list with a single account ID is passed to a method, whose purpose is to recursively go through levels of child accounts:
public static void Get_Children(ID mainID, List<ID> ID_Group){
for(Account child :[SELECT ID, ParentID FROM Account WHERE ParentID = :mainID]){
if(child.ParentId == mainID){ /*IF clause to make sure SOQL returned an actual account*/
ID_Group.add(child.id);
Get_Children(child.id, ID_Group);
}
}
}
Note that the method doesn't return the list, it simply populates it. If I have a method in which the ID_Group list is declared, then pass that list into this method, and then look at the ID_Group list afterwards, will it have the data loaded in by this method?