title: Java - ArrayList set using Rectangle2D.Double
body: <p>I've created this just to test things outside my main program. I got this error in my main program and am attempting to fix it now. I'm not sure if this is the best way to go about this, however I have an ArrayList and wish to be able to either replace the values in it to something that wont ever be possible to be hit. Or remove it from the array without affecting the length and the other values. So poisition 0 is still 0. Position 4 is still position 4 regardles if possition 2 has been removed. Here is my current code.</p>
  
  <pre><code>import java.util.ArrayList;
  import java.awt.geom.Rectangle2D;
  
  public class Main
  {
      public static void Main(String [] args)
      {
          ArrayList xcoords = (new Objects()).xco();
  
          for( int x = 0 ; x &lt; xcoords.size() ; x++ )
          {
              System.out.println(xcoords.get(x));
          }
  
          System.out.println("Start Replace");
          xcoords.set(0,10,15,34,54);
          System.out.println("End replace");
  
          for( int x = 0 ; x &lt; xcoords.size() ; x++ )
          {
              System.out.println(xcoords.get(x));
          }
      }
  }
  </code></pre>
  
  <p>And my objects class</p>
  
  <pre><code>import java.util.ArrayList;
  import java.awt.geom.Rectangle2D;
  
  public class Objects
  {
      ArrayList&lt;Integer&gt; xco()
      {
          ArrayList rectangles = new ArrayList();
  
          rectangles.add((new Rectangle2D.Double(5,10,20,100) ) );
          rectangles.add((new Rectangle2D.Double(4555,1566,20,100) ) );
          rectangles.add((new Rectangle2D.Double(73,45,20,100) ) );
          rectangles.add((new Rectangle2D.Double(1463,98623,20,100) ) );
  
          return rectangles;
      }
  }
  </code></pre>
  
  <p>Error</p>
  
  <p><img src="https://i.stack.imgur.com/3KOE6.png" alt="Error Code"></p>
  
  <p>So, is there an easior way using ArrayLists to get the desiered function and how would I go about 'setting' the value in the arraylist.</p>
  
  <p>Thanks, Kyle.</p>