0

我正在研究一个类,它是一个后端类的视图,需要显示一些后端类属性。

public abstract class AGenericNodeView{
    private ANode fObject;  
    private ArrayList<TInputView> fInputs = null;

    public AGenericNodeView(){
        super();
        this.fInputs = new ArrayList<TInputView>();
    }


    private void getInputs(){
        int num = fObject.getNumInputs(); //Number of inputs
        for (int i = 0; i < num; i++)
        {
            this.fInputs.add(new TInputView());
            this.fInputs.get(i).doSth();  
        }
        //fInputs has now the size num which is greater than 0. 
    }    

   //later I call:
   public draw()
   {
      //...
      log(this.fInputs.size()); //output fInputs.size()
      // and it is 0. Always. 
   }


}

我想知道,是否有办法让我创建的对象保持getInputs()持久性,以便列表在需要时不为空draw()

4

1 回答 1

1

几个建议:

  1. 使用调试器。

  2. 登录num_getInputs

  3. 登录System.identityHashCode(fInputs)并验证它们是否相同getInputsdraw

于 2013-03-14T13:46:54.903 回答