Java: How to build objects inside a while loop
Posted on 2011-09-03
I need to create many new objects inside the while loop. All objects must have a different name. Here's my code:
Card exampleObj = new Card(cardsArray[counter], cardsArray[counter+1]);
counter += 3;
The problem with this code is that it will only create 1 new object called exampleObj.
I would like to create many new objects all with different names as in: exampleObj1, exampleObj2, etc...
Even better would be to create these objects and call them Obj "cardsArray[counter], cardsArray[counter+1]"
Let me know if that last part made any sense?