add objects with different name through for loop
Posted
by Gandalf StormCrow
on Stack Overflow
See other posts from Stack Overflow
or by Gandalf StormCrow
Published on 2010-03-12T13:08:09Z
Indexed on
2010/03/12
13:27 UTC
Read the original article
Hit count: 134
java
|best-practices
What is the best way to do the following:
List<MyObject> list = new LinkedList<MyObject>();
for(int i=0; i<30;i++)
{
MyObject o1 = new MyObject();
list.add(o1);
}
But the things is I don't wanna create objects with same name, I wanna create them with different name like o1,o2,o3,o4,o5,o6,o7,o8,o9,o10
and I wanna add each to the list. What is the best way to do this ?
© Stack Overflow or respective owner