title: Modifying an ArrayList within an ArrayList
body: <p>I have three classes. The Player Class:</p>
  
  <pre><code>public class Player
  {
  private String playerName;
  private int playerWorth;
  private int playerSpent;
  // A list of player prize objects.
  private ArrayList&lt;Prize&gt; playerPrizeList;
  
  public void Player()
  {
       playerPrizeList = new ArrayList &lt;Prize&gt;();
       playerName = "";
       playerWorth = 0;
       playerSpent = 0;
  }
  
  public void playerDetails(String playerName, int playerWorth, int playerSpent)
  {
      setPlayerName(playerName);
      setPlayerWorth(playerWorth);
      setPlayerSpent(playerSpent);
  }
  
  public void prize(String prizeName, int prizeWorth, int prizeCost)
  {
      populatePrize(prizeName, prizeWorth, prizeCost);
  }
  
  private void populatePrize(String prizeName, int prizeWorth, int prizeCost)
  {
      playerPrizeList.add(new Prize(prizeName, prizeWorth, prizeCost));
  }
  </code></pre>
  
  <p>The other class is PlayerList class from within which I am trying to add a new player object to an arrayList which works but then I also have a prizeList Array of (Prize Objects) inside this Player class. Once I add the player to the ArrayList how do I retrieve that object and make changes to (my last block of code). I hope I explained that properly.</p>
  
  <pre><code>public class PlayerList
  {
  private ArrayList&lt;Player&gt; playerAList; 
  
  public PlayerList() 
  {
      playerAList = new ArrayList&lt;Player&gt;();
  }
  
  public ArrayList&lt;Player&gt; addPlayer(String playerName, int playerWorth, int playerSpent)
  {
      Player newPlayer = new Player();
      newPlayer.setPlayerName(playerName);
      newPlayer.setPlayerWorth(playerWorth);
      newPlayer.setPlayerSpent(playerSpent);
      playerAList.add(newPlayer);
      return playerAList;
  }
  
  /**
   * @i is the index of ArrayList for Player Prizes
   */
  public void setPlayerPrizeList(int i, String prizeName, int prizeWorth, int prizeCost)
  {
      playerAList.get(i) =  currentPlayer;
      currentPlayer.populatePrize(prizeName, prizeWorth, prizeCost);
      playerAList.set(i, currentPlayer);
      return playerAList;
  }
  </code></pre>