配列を作成するかstatic
(@Jigarの提案に従って-ユニットテストと同時実行性の問題のため、これは推奨されませんが)、できればの適切なインスタンスをFirst
に渡しますThird
。例えば
class First {
public Object[] array = ...;
}
class Second {
public fillArrayAndPassItToThird(Third third) {
First first = new First();
// fill in the array...
// then pass it to Third
third.processArrayFromFirst(first);
}
}
class Third {
public void processArrayFromFirst(First first) {
// process First.array
}
}
First
または、依存関係を減らすために、オブジェクト全体ではなく、配列自体のみを渡すことをお勧めします。
third.processArrayFromFirst(first.array);
...
public void processArray(Object[] array) {