Return from a private method?
I have a simple question regarding design of private methods. If I have private methods within my class that are performing tasks, such as populating ArrayLists for use within the class only, is it acceptable practice to return the ArrayLists from the private method that is building them? Or should I simply declare each ArrayList I am building as an instance variable and the private method sets the instance variable?
For instance, should it be this way:
publicvoid runBatch(){
List list = this.buildList();
this.searchList(list);
}
private List buildList(){
List methodList =new ArrayList();
// build logic
return methodList;
}
Or:
List list =new ArrayList();
publicvoid runBatch(){
this.buildList();
this.searchList(list);
}
privatevoid buildList(){
list.add("test1");
list.add("test1");
}

