DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

How does AI transform chaos engineering from an experiment into a critical capability? Learn how to effectively operationalize the chaos.

Data quality isn't just a technical issue: It impacts an organization's compliance, operational efficiency, and customer satisfaction.

Are you a front-end or full-stack developer frustrated by front-end distractions? Learn to move forward with tooling and clear boundaries.

Developer Experience: Demand to support engineering teams has risen, and there is a shift from traditional DevOps to workflow improvements.

Related

  • DataWeave Interview Question: Concatenate Elements of an Array
  • ConcurrentHashMap: Call Only One Method Per Key
  • Floyd's Cycle Algorithm for Fraud Detection in Java Systems
  • Merge Multiple PDFs in MuleSoft

Trending

  • Complete Guide: Managing Multiple GitHub Accounts on One System
  • Why 99% Accuracy Isn't Good Enough: The Reality of ML Malware Detection
  • It’s Not Magic. It’s AI. And It’s Brilliant.
  • Code of Shadows: Master Shifu and Po Use Functional Java to Solve the Decorator Pattern Mystery
  1. DZone
  2. Data Engineering
  3. Data
  4. A Look at Java Collections

A Look at Java Collections

In a kickoff to a series on the Java Collections framework, we look at the hierarchy and an overview of uses. It's more than just generic lists, maps, and sets!

By 
Jay Sridhar user avatar
Jay Sridhar
·
Feb. 27, 17 · Tutorial
Likes (50)
Comment
Save
Tweet
Share
31.2K Views

Join the DZone community and get the full member experience.

Join For Free

The Java Collections framework is an architecture for storing, managing, and manipulating collections of objects. It provides many data structures and algorithms commonly used for dealing with collections — searching and sorting, for instance. Many details about storing objects are abstracted away (meaning you do not have to deal with it in code). A unified interface is provided to manipulate them, for example for adding and removing entries.

The Collections Hierarchy

The Collections Framework is organized into a class hierarchy, which can be understood at a glance from the picture below.

Note: The hierarchy shown below includes only the most common and useful classes and interfaces. Some have been skipped to facilitate easier understanding.

Image title

Java Collections Framework

A Brief Introduction to Collections

  1. At the root of the hierarchy is Iterable which, as the name indicates, provides for iterating over the collection.
  2. The next is the Collection interface, which provides most of the methods representing a collection. These methods include providing for adding and removing elements, checking if the collection includes an element, and obtaining the number of elements in the collection.
  3. A Set contains no duplicate elements. Common implementations are:
    • HashSet does not provide any ordering of the elements in the Set.
    • LinkedHashSet maintains a double-linked list of the elements and thus provides a predictable iteration order.
    • TreeSet which uses a comparator function to maintain element ordering.
  4. A List is an ordered sequential collection. Concrete implementations include:
    • ArrayList is a re-sizable list backed by an array.
    • Vector is also a re-sizable array similar to an ArrayList. Use it only when you need thread-safety and synchronization.
    • Stack is a LIFO(Last-In-First-Out) array. A subclass of Vector and is also thread-safe.
    • LinkedList is a doubly linked list of elements. Offers fast adds and removes from intermediate positions. Note that this class also implements the Deque interface.
  5. A Queue orders elements in a FIFO (First-In-First-Out) order. The add() method adds elements at the tail and remove() removes elements from the head. Typical usage is storage to hold elements before processing in the order of receipt.
  6. On the other hand, a Deque (Double-Ended-Queue) can add and remove elements at both ends.
    • ArrayDeque is an implementation of Deque using an array for storage.
    • A LinkedList is also a Deque.

Summary

This article presented a brief overview of the Java Collections hierarchy. In further articles, we explore the various collection classes and their usage.



If you enjoyed this article and want to learn more about Java Collections, check out this collection of tutorials and articles on all things Java Collections.

Java (programming language) Element Data structure

Published at DZone with permission of Jay Sridhar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • DataWeave Interview Question: Concatenate Elements of an Array
  • ConcurrentHashMap: Call Only One Method Per Key
  • Floyd's Cycle Algorithm for Fraud Detection in Java Systems
  • Merge Multiple PDFs in MuleSoft

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • [email protected]

Let's be friends: