Bably Das wrote:I think I need to change the name of the Room class to a more appropriate name of Record class.
There are different ways to create a unique identity for each object. The ID could be automatically generated by a module, and used internally in the software without making it visible to the user. It can be a primary key in a database table, which is assured to be unique in the database.
I like to add a small remark (just for completeness, because you all know this): a list doesn't behave like a map, so if you use yourArrayList.add(0, null) you have also to call first yourArrayList.remove(0) (or you can afterwards call yourArrayList.remove(1)). Otherwise you are adding an empty record, instead of deleting an existing one. That's why I prefer the Map.
Roberto Perillo wrote:What you can do is keep the Room object in a List, and if the record is deleted, then the entry is null (something like, if record 1 is deleted, then yourArrayList.add(0, null)). But you'll have to remember that the entry 0 is record 1, entry 1 is record 2, and so on... and when you delete a record, then you simply set its entry to null.
Roel De Nijs wrote:so if you use yourArrayList.add(0, null) you have also to call first yourArrayList.remove(0)