title: arraylist remove eliminates following objects
body: <p>I'm getting a very strange action in my code. I have an <code>ArrayList</code> of the following class.</p>
  
  <pre><code>class mySocket 
  {
      public String name;
      public Socket sck;
      public mySocket(String n,Socket s)
      {
          this.name=n;
          this.sck=s;
      }
  }
  </code></pre>
  
  <p>I declare the object like this</p>
  
  <pre><code>ArrayList&lt;mySocket&gt; handler = new ArrayList&lt;&gt;();
  </code></pre>
  
  <p>Now the problem is that when I try to remove an item using this method:</p>
  
  <pre><code>public void removeByName(String name)
  {
      synchronized(this)
      {
          mySocket t;
          int i;
          for(i=0;i&lt;handler.size();i++)
          {
              t=handler.get(i);
              if((t.name.equals(name)))
              {
                 handler.remove(i);
                 break;
              }
          }
      }
  }
  </code></pre>
  
  <p>The remove function clears everything that follows the index.<br>
    For Example:<br>
  if this <code>ArrayList</code> has 3 elements and I call <code>handler.remove(1)</code> it removes not only 1 but also the object on line 2.</p>