File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 14114
    
  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