About 51 results
Open links in new tab
  1. 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 …

  2. java - List.of () or Collections.emptyList () - Stack Overflow

    Collections.emptyList() does not need to create a new object for each call; it's typical, as in OpenJDK, to just return the singleton EMPTY_LIST object. Additionally, it's clearer that you intend to mean an …

  3. java - What is the difference between "collection" ,"Collection" and ...

    Apr 15, 2017 · The Java collections framework (JCF) is a set of classes and interfaces that implement commonly reusable collection data structures. Collection is an interface .

  4. Java Immutable Collections - Stack Overflow

    20 Now java 9 has factory Methods for Immutable List, Set, Map and Map.Entry . In Java SE 8 and earlier versions, We can use Collections class utility methods like unmodifiableXXX to create …

  5. collections - Easiest way to convert a List to a Set in Java - Stack ...

    12 Remember that, converting from List to Set will remove duplicates from collection because List supports duplicates but Set does not support duplicates in Java. Direct Conversion : The most …

  6. How to use Collections.sort () in Java? - Stack Overflow

    Collections.sort(recipes); return recipes; } But now, in a different method, lets call it getRecipesSort(), I want to sort the same list but numerically, comparing a variable that contains their ID. To make …

  7. How to count the number of occurrences of an element in a List

    Feb 3, 2009 · 8 Actually, Collections class has a static method called : frequency (Collection c, Object o) which returns the number of occurrences of the element you are searching for, by the way, this will …

  8. What is the most efficient Java Collections library? [closed]

    What is the most efficient Java Collections library? A few years ago, I did a lot of Java and had the impression back then that trove is the best (most efficient) Java Collections implementation. ...

  9. collections - What are the differences between a HashMap and a ...

    What are the differences between a HashMap and a Hashtable in Java? Which is more efficient for non-threaded applications?

  10. ¿Cuál es la función de la clase Collections en Java?

    Jul 6, 2017 · Collections.sort(tasks, comparadorFecha); //ok showTask(); } Ahora sí, comparadorFecha, y comparadorPrioridad deben ser instancias de alguna clase que implemente la interfaz …