About 23,900,000 results
Open links in new tab
  1. java - Sort objects in ArrayList by date? - Stack Overflow

    Every example I find is about doing this alphabetically, while I need my elements sorted by date. My ArrayList contains objects on which one of the datamembers is a DateTime object. On DateTime I ...

  2. Sort a Java collection object based on one field in it

    Have a look at the Comparator and Collections classes. A simple way would be to implement the Comparable interface in AgentSummaryDTO and then pass the list to Collections.sort().

  3. Java Immutable Collections - Stack Overflow

    Unmodifiable collections are usually read-only views (wrappers) of other collections. You can't add to, remove from or clear them, but the underlying collection can change. Immutable collections can't be …

  4. How to use Comparator in Java to sort - Stack Overflow

    Again, to use Collections.sort, you need one of these to be true: The type must be Comparable (use the 1-arg sort) A Comparator for the type must be provided (use the 2-args sort) When to use …

  5. A Java collection of value pairs? (tuples?) - Stack Overflow

    Eclipse Collections If you're using pairs that contain primitives, Eclipse Collections provides some very efficient primitive pair classes that will avoid all the inefficient auto-boxing and auto-unboxing.

  6. Checking if a collection is empty in Java: which is the best method?

    The other advantage of using Apache commons-collections CollectionUtils.isEmpty (or CollectionUtils.isNotEmpty) is that your if condition has less branches, so it is easier to reach a good …

  7. java - Collections.sort with multiple fields - Stack Overflow

    I have a list of "Report" objects with three fields (All String type)- ReportKey StudentNumber School I have a sort code goes like- Collections.sort(reportList, new Comparator<Report>() { @

  8. Java: Best way to iterate through a Collection (here ArrayList)

    Today I was happily coding away when I got to a piece of code I already used hundreds of times: Iterating through a Collection (here ArrayList) For some reason, I actually looked at the autocompl...

  9. java collections - keyset() vs entrySet() in map - Stack Overflow

    java collections - keyset () vs entrySet () in map Asked 13 years, 10 months ago Modified 6 years, 10 months ago Viewed 122k times

  10. java - Array to Collection: Optimized code - Stack Overflow

    But this is not the java.util.ArrayList. It's very similar though. Note that this constructor takes the array and places it as the backing array of the list. So it is O(1). In case you already have the list created, …