Firstly, in Java there is no "pass by reference": the language passes links by value (this is not the same thing).
: " ": , .
: , . , .
interface DataSource {
void supplyData(List<Data> list);
}
:
interface DataSource {
List<Data> supplyData();
}
, :
List<Data> bigList = new ArrayList<Data>();
foreach (DataSource s : mySources) {
s.supplyData(bigList);
}
supplyData , :
List<Data> bigList = new ArrayList<Data>();
foreach (DataSource s : mySources) {
List<Data> tmp = s.supplyData();
bigList.addAll(tmp);
}
tmp, .
, - , .
, , . DataSource , , , , , ..