How to add an element to an array without a modification of the old array or creation a new one?

Posted by Roman on Stack Overflow See other posts from Stack Overflow or by Roman
Published on 2010-03-22T14:40:04Z Indexed on 2010/03/22 14:41 UTC
Read the original article Hit count: 283

Filed under:
|

I have the following construction: for (String playerName: players).

I would like to make a loop over all players plus one more special player. But I do not want to modify the players array by adding a new element to it. So, what can I do?

Can I replace players in the for (String playerName: players) by something containing all elements of the players plus one more element?

© Stack Overflow or respective owner

Related posts about java

Related posts about arrays