title: How to store Clients in a list
body: <p>I am running a server, and I have an arraylist of type Client 
  When a client connects through 
      ServerSocket.accept()
  I pass the new Socket to the arraylists constructor. This is everything inside the constructor </p>
  
  <pre><code>this.add(new Client(Socket client));
  </code></pre>
  
  <p>My problem is when a client disconnects, it closes the Socket, but it doesn't delete its spot in the arraylist, and shift everything down one. So the arraylist is constantly growing bigger.</p>
  
  <p>What can I do/use to fix this problem?</p>
  
  <p>Sometimes I will run commands that will execute on all clients which is why I store the clients in an arraylist. </p>
  
  <p>Is there a better alternative for storing clients in a server? </p>
  
  <p><strong>Update 1</strong></p>
  
  <p>The classes are in the beginning stages. Very little has been implemented. So far the HashMap option suggested in the answer works best for me. Thank you for your replies</p>