Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Hashcode not removing duplicates from set

 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 15748
74
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper, Thanks for your help. That was the problem.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!