java - How can I create a variable that will contained an unknown number of objects? -
i have procedure recursively generates objects. procedure takes "last" object , generate "new" one, "new" object considered "last" 1 , on until "new" object cannot generated.
i need save generated object. thought use array problem not know in advance how many objects generated (so, cannot specify length of array when declare it).
is there way in java have arrays without fixed length? or may should use not array else?
go arraylist
list<yourclass> list = new arraylist<yourclass>(); list.add(obj1); list.add(obj2); list.add(obj3); . . .
Comments
Post a Comment