So, I was thinking of creating a list of objects like this
ArrayList<Obj> lst = new ArrayList<Obj>(10); for (int i = 0; i < 10; i++) { Obj elem = new Obj(); lst.add(elem); }
Is this legal, or do I need to worry about object 1 getting garbage when the elem link starts pointing to Object 2? If it is illegal, how can I do it otherwise? Is there a way to automatically generate ten different link names?
source share