Hi, I have a question about whether to use ArrayList or HashMap .
I am trying to create a Paint program. Each depicted object is assigned a unique object ID .
If I want to quickly get speed when I click on an object, should I use ArrayList or HashMap ?
In general, hashmap has O (1), while arraylist has O (n) output speed.
However, I think for my case, since when I click on an object, I will get an identifier, hence the index of the array, and I can do something like ArraylistObject.get (ithElement) ;, so in this case it will also be O (1) search process?
any inputs?
Thanks!
arraylist hashmap
freshWoWer
source share