Basically you need to look up ArrayList
element based on name getName
. Two approaches to this problem:
1- Don't use ArrayList
, Use HashMap<String,AutionItem>
where String
would be name
2- Use getName
to generate index and use index based addition into array list list.add(int index, E element)
. One way to generate index from name would be to use its hashCode and modulo by ArrayList
current size (something similar what is used inside HashMap
)