Java - java.util.List problem

Posted by Yatendra Goel on Stack Overflow See other posts from Stack Overflow or by Yatendra Goel
Published on 2010-04-15T16:41:50Z Indexed on 2010/04/15 16:53 UTC
Read the original article Hit count: 128

Filed under:
|
|

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 Items.

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about arraylist