title: Adding Colors to a Color array
body: <p>I am writing a program where I take an image determine the average red channel, green channel and blue channel present in that image. I take these averages and pass them as parameters to a new color. I then want to add this color to an array. I repeat this process 24 times. The problem I face is that when I get a new color and add it to the array the previous colors get erased. I want to preserve the existing colors in the array and add to the one that hasn't been filled yet. Here is what I have tried.</p>
  
  <pre><code>System.out.println("R: "+ rAvg);
  System.out.println("G: "+ gAvg);
  System.out.println("B: "+ bAvg);
  
  
  Color newColor = new Color(rAvg, gAvg, bAvg);
  Color[] ColorArr = new Color[24];
  
  for(int i = 0; i &lt; ColorArr.length; i++){
       ColorArr[i] = newColor;
          }
  
  System.out.println(Arrays.toString(ColorArr));
  </code></pre>
  
  <p>Here is the output after one color is added to the array </p>
  
  <pre><code> R: 206
   G: 0
   B: 0
   [java.awt.Color[r=206,g=0,b=0],java.awt.Color[r=206,g=0,b=0]
  </code></pre>
  
  <p>Here is the array after I add a new color.</p>
  
  <pre><code>R: 211
  G: 178
  B: 230
  [java.awt.Color[r=211,g=178,b=230], java.awt.Color[r=211,g=178,b=230]
  </code></pre>
  
  <p>The last color gets overwritten and replaced with the new color instead of going in the next index and preserving the last. How can I fix this so I preserve the entered colors in the array and place the new color the index after the previous?</p>