I need some help. I want to create a for loop that creates n number of objects of a class, and then adds them into an arraylist. Something like this:
//Player is a custom class
ArrayList<Player> numberofPlayersArray;
numberofPlayersArray = new ArrayList<Player>();
//n is a variable for the number of Player class objects that I want to create
for(int i = 0; i < n; i++)
{
//this is what I can come up with but I am missing something
Player p;
p = new Player
numberofPlayersArray.add(p);
}
Any help would be appreciated