Using Iterator with LinkedList

I'm trying to use an iterator in a method to count the number of duplicates in a list of integers. I have a logic problem in it somewhere because it only counts one set of duplicates every time even if there's more than one. Here's the code:

Thanks, Dave

Dave DiRito
Ranch Hand

Joined: Feb 08, 2008
Posts: 77

posted Apr 02, 2008 18:41:00

0

Just figured it out:

Dave DiRito
Ranch Hand

Joined: Feb 08, 2008
Posts: 77

posted Apr 02, 2008 18:58:00

0

Also, the list must be sorted for this method to work. I used Collections.sort(list); before passing the list to the method.