0

HashSet only contains unique element? what is the best scenario to use HashSet instead of List. Both have approximately same function.

khan
  • 127
  • 1
  • 4
  • 11
  • 1
    No, they're very different. Do you want an ordered list of values which can include duplicates? Use `List`. Do you want an unordered *set* of values (so no duplicates)? Use `HashSet`... – Jon Skeet Nov 23 '15 at 12:47
  • read this http://stackoverflow.com/questions/17985029/hashset-vs-arraylist – Kumar Saurabh Nov 23 '15 at 12:48
  • and this http://stackoverflow.com/questions/21974361/what-java-collection-should-i-use – Tim B Nov 23 '15 at 15:47

0 Answers0