I have a java.util.ArrayList<Item>
and an Item
object.
Now, I want to obtain the number of times the Item
is stored in the arraylist.
I know that I can do arrayList.contains()
check but it returns true, irrespective of whether it contains one or more Item
s.
Q1. How can I find the number of time the Item is stored in the list?
==================================================================================
Q2. Also, If the list contains more than one Item, then how can I determine the index of other Items because arrayList.indexOf(item)
returns the index of only first Item every time?