title: How would I iterate through an array of colors so the color changes each mouseclick?
body: <p>So I want to iterate through an array of colors upon mouseclick and when it reaches the end of the array go back to the 0 space in the array.</p>
  
  <pre><code> private Color _color = Color.BLACK;
   private Color[] _arrayOfColors = new Color[]{Color.GREEN, Color.RED, Color.BLUE, Color.BLACK};
  
  @Override
  public void paint(Graphics g)
  {
      g.setColor(_color);
      g.drawRect(_x, _y, _size, _size);
  }
  
  @Override
  public void mousePressed(MouseEvent mev)
  {
      for(int i = 0; i&lt;_arrayOfColors.length; i++)
      {
          _color = _arrayOfColors[i];
      }
  }
  </code></pre>