What data structure should I use for object storage, for easily generating primary keys for new entries?
<p>I'm doing a school project in Java and I the following question have arisen:</p>

<p>I have an entity with attributes - id, name, phone.. with id as the unique primary key. I want to store them in a data structure(such as list..). Then in the application I obtain the data for creating a new instance (name, phone..) and I want to create a new instance of the entity and store it in my data structure with a new unique id. The id shouldn't be random, it would be best if the id rised continuously with the size of the list. Also I dont want to reuse ids.</p>

<p>The first implementation that comes to my mind is to use ArrayList and simply set id as indexes. But <code>ArrayList.remove(int index)</code> after removal shifts all following elements to left. I assume that <code>ArrayList.remove(Object o)</code> works the same, but i would be gratefull i I'm proven wrong. Determining ids from last element would not work either. I could go through all of them but that seems inefiicient.</p>

<p>Thanks in advance for any help :)</p>
