Java: Are these 2 codes the same?
- by Kevin Duke
for (Player p : players)
{
p.addCard(deck.dealCard());
p.addCard(deck.dealCard());
}
and
for (int i = 0; i < players.size() ; i++)
{
Player p = players.get(i);
p.addCard(deck.dealCard());
p.addCard(deck.dealCard());
}
The second code yeilds a null pointer exception, what can be done to make the bottom one equivalent ?