Is an ArrayList automatically declared static in Java, if it is an instance variable?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-05-09T07:44:28Z Indexed on 2010/05/09 8:08 UTC
Read the original article Hit count: 218

Filed under:
|
|
|
|

I'm trying to do something like this:

private class aClass
{
  private ArrayList<String> idProd;

  aClass(ArrayList<String> prd) 
  {
      this.idProd=new ArrayList<String>(prd);
  }

public ArrayList<String> getIdProd()
  {
      return this.idProd;

  }
}

So if I have multiple instances of ArrayLIst<String> (st1 ,st2 ,st3) and I want to make new objects of aClass:

{
 aClass obj1,obj2,obj3;
 obj1=new aClass(st1);
 obj2=new aClass(st2);
 obj3=new aClass(st3);
}

Will all of the aClass objects return st3 if I access the method getIdProd() for each of them(obj1..obj3)? Is an ArrayList as an instance variable automatically declared static?

© Stack Overflow or respective owner

Related posts about java

Related posts about static