开发者

help with this section of the work, arraylists objects lists

开发者 https://www.devze.com 2023-02-15 01:53 出处:网络
private List<MyShape> childShapes; public ShapeCreator() { super(); frame = new DrawGUI(); this.childShapes = new ArrayList<MyShape>();
private List<MyShape> childShapes;
public ShapeCreator() {
    super();
    frame = new DrawGUI();
    this.childShapes = new ArrayList<MyShape>();
}

I have this piece of code and i have got to insert an infinite amount of data(th开发者_C百科e array size not fixed), which consists of integers, how would i do that, i think i must be getting confused with the this.childShapes

I would appreciate some help thanks


I could not say you formulated your question well enough... but i'll make my suggestion:

you probably want to have a method that will take the new data in as argument and insert it into the list of childShapes;

public void addShape(int whateverInt){
   childShapes.add(new MyShape(whateverInt));
}

That should do. You can call this method as many times as you like... until you run out of memory. There's no such thing as infinite amount of data. :-)

0

精彩评论

暂无评论...
验证码 换一张
取 消