wood burning stoves 2.0*
The moose likes Java in General and the fly likes Hashcode not removing duplicates from set Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

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://aspose.com/file-tools
 
subject: Hashcode not removing duplicates from set
 
Similar Threads
Head First Java HashSet
Model or bean class is not available to Action Class
when and how is compareTo() called for each element
Sorting on int field of object
compareTo( )