title: How to change an element in a list of lists Java
body: <p>This is a peice of my code, i am making a grid of 5x5 with random colors set to each section. I need to set the specified y_loc and x_loc in the list to the color randomly picked except i have not been able to find out how. It should be the second last line that is not operating as id like. I understand that i could do this in much much longer code but it would be nice to do it in less.</p>
  
  <pre><code>//making the map
      ArrayList&lt;ArrayList&lt;String&gt;&gt; fullmap = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
      ArrayList&lt;String&gt; y_row_0 = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; y_row_1 = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; y_row_2 = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; y_row_3 = new ArrayList&lt;String&gt;();
      ArrayList&lt;String&gt; y_row_4 = new ArrayList&lt;String&gt;();
  //adding each row
      fullmap.add(y_row_0);
      fullmap.add(y_row_1);
      fullmap.add(y_row_2);
      fullmap.add(y_row_3);
      fullmap.add(y_row_4);
      Random rn = new Random();
      //loop to randomly pick colors then set them to their destined locations
      for (int y_loc = 0; y_loc &lt; 6; y_loc++){
          for (int x_loc = 0; x_loc &lt; 6; x_loc++){
              colorPicked = false;
              while (!colorPicked){
                  int ranNum = rn.nextInt();
                  if (ranNum ==0){
                      if (redTot &lt; 5) {
                          redTot += 1;
                          fullmap.set(y_loc).set(x_loc, "Red"));
                          colorPicked = true;
  </code></pre>