About 46,200 results
Open links in new tab
  1. Any implementation of Ordered Set in Java? - Stack Overflow

    Jan 3, 2012 · 174 Take a look at LinkedHashSet class for insertion-order, implementing SequencedSet & Set interfaces. From Java doc: Hash table and linked list implementation of …

  2. sorting - Java Set retain order? - Stack Overflow

    May 25, 2012 · Does a Java Set retain order? A method is returning a Set to me and supposedly the data is ordered but iterating over the Set, the data is unordered. Is there a better way to …

  3. Order of elements in a set in java - Stack Overflow

    Jun 18, 2017 · As per documentation public ArrayList (Collection c) Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's …

  4. java - Sorting values of a Set of String representations of integers ...

    Jul 17, 2025 · The issue here is that the order in which you added the elements to the set {"12", "15", "5"} are already coincidentally in sorted order (as defined by the String class), so sorting …

  5. Ordering of elements in Java HashSet - Stack Overflow

    Feb 19, 2012 · Hash table and linked list implementation of the Set interface, with predictable iteration order. This implementation differs from HashSet in that it maintains a doubly-linked …

  6. java - How to sort a HashSet? - Stack Overflow

    For lists, we use the Collections.sort(List) method. What if we want to sort a HashSet?

  7. How can I preserve insertion order in a HashSet? - Stack Overflow

    Jul 2, 2018 · A Set that further provides a total ordering on its elements. The elements are ordered using their natural ordering, or by a Comparator typically provided at sorted set creation time. …

  8. How to keep order in Java 9 Set.of - Stack Overflow

    Sep 3, 2018 · I've noted while testing that the new Set.of method of Java 9 doesn't return an ordered implementation of a Set. How can I use such utilities and still get an ordered …

  9. java - Is there an insertion order preserving Set that also …

    Sep 7, 2015 · TreeSet is sorted by element order; LinkedHashSet retains insertion order. Hopefully one of those is what you were after. You've specified that you want to be able to …

  10. java - What is the difference between an ordered and a sorted ...

    Mar 16, 2016 · An ordered collection is a collection that keep track of a consecutive index which every element is inserted in. A sorted collection is an ordered collection when the order …