The Best of Java Collections [Tutorials]
The Best of Java Collections [Tutorials]
The Java Collections Framework (JCF) has become ubiquitous among Java developers.
Join the DZone community and get the full member experience.Join For Free
When it comes to building Java applications, the Java Collections Framework (JCF) has become ubiquitous among developers. Since the release of JDK 2, Java objects and data structures have changed development for the better, boosting performance and reducing programming efforts.
Oracle defines collections and the JCF as:
"An object that represents a group of objects (such as the classic Vector class). A collections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details."
Below, you can find a number of articles dedicated to breaking down the JCF architecture, as well as tutorials on performance, Collection interfaces, and Maps. Enjoy!
Overview of Collections
Justin Albano's series The Developer's Guide to Collections: Lists and Sets— It's time for a deep dive into collections in Java, including the defining philosophy of collections, important methods, and advice for implementation.
Check out these stellar posts from Jay Sridar: A Look at Java Collections and Java Collections: The List and Collections Interfaces. These two posts will cover everything you need to know when getting started with the Collections framework.
Iteration Over Java Collections With High Performance by Dang Ngoc Vu — Learn more about the
forEach loop in Java and how it compares to C style and Stream API in this article on dealing with collections in Java.
Performance Evaluation of Java ArrayLists by Viraj Salaka, Malith Jayasinghe, Isuru Perera, and Srinath Perera — Here's a performance breakdown of the ArrayList add operation to see how to get the most throughout out of your ArrayLists.
How to Prevent Your Java Collections From Wasting Memory by — Wondering about the memory impact of your Java collections? Here's how to think about your collections while keeping overhead in mind.
Performance Analysis of ArrayList and LinkedList in Java by Anant Mishra —
LinkedList are frequently used classes in the Java collection framework. If you know only understand basic performance comparisons of
LinkedList, but not the minor details of these two classes, then this article is for you.
[DZone Refcard] Java Performance Optimization by Pierre-Hugues Charbonneau — Getting Java apps to run is one thing. But getting them to run fast is another. This Refcard covers JVM internals, class loading (updated to reflect the new Metaspace in Java 8), collections, troubleshooting, monitoring, concurrency, and more.
Convenience Factory Methods for Collections in Java 9 by Bartłomiej Słota — Java 9 brings with it some new convenience methods for dealing with collections. Here, we look at the role they play in Lists, Sets, and Maps.
How to Easily Create Lists, Sets, and Maps in Java [Video] by Marco Behler — Check out this post to learn how easy it is to create lists, sets, and maps from Java 9 onwards.
How to Convert Between List and Array in Java by John Thompson — Want to learn more about converting a list to an array in Java? Check out this tutorial to learn more using the Apache Commons Lang and Guava.
How to Convert Array to ArrayList in Java by Ryan Wang — This one is an oldie-but-a-goodie. Every Java programmer knows ArrayList — while the concept itself is relatively simple, it can be easy to make mistakes. Here's how to convert an Array to an ArrayList with no mistakes.
Different Approaches to Sorting Elements of an ArrayList in Java by John Thompson — Learn different approaches for sorting elements of an ArrayList — one using Comparable and the other using Comparator.
How to Convert an Array to a String in Java [Code Snippet] by Ramesh Fadatare — Learn the different ways to convert arrays and/or integers to a string.
Sets and Queues
The Developer's Guide to Collections: Sets by Justin Abano — Time for another deep dive into Java collections! This time, we focus on the concept of sets, the set interface, and everything you can do with sets.
HashSet Vs. TreeSet Vs. LinkedHashSet by Ryan Wang — In a set, there are no duplicate elements. That is one of the major reasons to use a set. There are three commonly used implementations of Set in Java: HashSet, TreeSet, and LinkedHashSet.
HashMap Vs. TreeMap Vs. HashTable Vs. LinkedHashMap by Ryan Wang — We look at the most commonly used implementation of Map in Java and how to differentiate between use cases.
Removing Elements From a Map in Java by Dan Newton — This is a very short and simple post on removing elements from a
Map in Java, focusing on removing multiple elements and ignoring the fact that you can remove a single element using
Java HashMap Implementation in a Nutshell by Yogen Rai — Want to learn more about custom HashMap implementation in Java? Check out this tutorial on how we can implement this data structure using arrays.
Opinions expressed by DZone contributors are their own.