This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes Hashcode not removing duplicates from set Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Hashcode not removing duplicates from set" Watch "Hashcode not removing duplicates from set" New topic
Author

Hashcode not removing duplicates from set

Bud Tippins
Ranch Hand

Joined: Jan 28, 2011
Posts: 52
I have the following code. Lines 61 through 67 are supposed to be removing the duplicates from the list of titles coming from the file. However when I run this in NetBeans the duplicates appear. What do I need to do to have the duplicates removed?

Thank you for your help.

Jesper de Jong
Java Cowboy
Bartender

Joined: Aug 16, 2005
Posts: 12911
    
    3

Note that you are printing the songs three times: in lines 25, 27 and 32.

I guess that in line 32 you meant to print songSet, but you are printing songList. You're not printing the content of the HashSet anywhere.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Bud Tippins
Ranch Hand

Joined: Jan 28, 2011
Posts: 52
Jesper, Thanks for your help. That was the problem.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Hashcode not removing duplicates from set
 
Similar Threads
Head First Java HashSet
Sorting on int field of object
when and how is compareTo() called for each element
compareTo( )
Model or bean class is not available to Action Class