基本的に動的リストの参照を渡したい。Class2 では、元のリストが変更されても、getTheList メソッドは新しいリストを取得し続ける必要があります。リスナーを追加する必要がありますか、それともより良い方法で設計を変更する必要がありますか?
class1{
public class1(){
List orginalList=getOrginalList();
Class2 c2=new Class2(orginalList);
}
public List getOrginalList(){
//here read and return the updated orginal
//List from a web service
}
}
class2{
List myList;
public class2(List realList){
myList=realList;
}
private int getTheList(){
//when I call this method I want to get the updated list
return myList.size();
}
}