About 1,620,000 results
Open links in new tab
  1. java - How to initialize HashSet values by construction ... - Stack ...

    Jan 11, 2010 · NOTE: Some answers omit `new HashSet<T> (int initialCapacity) parameter, if you already know the size of the collection use it.

  2. Easiest way to convert a List to a Set in Java - Stack Overflow

    So, if you just care about uniqueness, use the HashSet. If you're after sorting, then consider the TreeSet. (Remember: Optimize later!) If time efficiency matters use a HashSet if space …

  3. java - Difference between HashSet and HashMap? - Stack Overflow

    Apart from the fact that HashSet does not allow duplicate values, what is the difference between HashMap and HashSet in their implementation? It's a little bit vague because both use hash …

  4. Why do I need to override the equals and hashCode methods in …

    Why we override hashCode() method Some Data Structures in java like HashSet, HashMap store their elements based on a hash function which is applied on those elements. The hashing …

  5. Java: Retrieving an element from a HashSet - Stack Overflow

    Aug 18, 2012 · 74 Why cannot I retrieve an element from a HashSet? Consider my HashSet containing a list of MyHashObjects with their hashCode() and equals() methods overridden …

  6. java - In which cases should I use a HashSet over a TreeSet?

    Java provides a LinkedHashSet, which is a HashSet with an "insertion-oriented" linked list running through it, that is, the last element in the linked list is also the most recently inserted into the …

  7. How to convert an Array to a Set in Java - Stack Overflow

    I would like to convert an array to a Set in Java. There are some obvious ways of doing this (i.e. with a loop) but I would like something a bit neater, something like: java.util.Arrays.asList(Obj...

  8. Union or intersection of Java Sets - Stack Overflow

    Jun 30, 2018 · What is the simplest way to make a union or an intersection of Sets in Java? I've seen some strange solutions to this simple problem (e.g. manually iterating the two sets).

  9. java - What's the difference between HashSet and Set? - Stack …

    Apr 16, 2016 · 1 HashSet is a class derived from Set interface. As a derived class of Set, the HashSet attains the properties of Set. Important and the most frequently used derived classes …

  10. java - Getting the difference between two sets - Stack Overflow

    package dev.onepub.util; import java.util.HashSet; import java.util.Set; public class Sets { /** * Calculates the delta of the two sets. * * The method assumes that you have an existing set * …