Description
Course info
Rating
(223)
Level
Beginner
Updated
Mar 7, 2016
Duration
4h 2m
Description

Working with data is fundamental to any business problem. Java Collections are data structures designed to store and process data in memory. We start with why you want to use collections instead of arrays, cover the capabilities of Lists, Sets, and Maps and explain the different data structure tradeoffs.

About the author
About the author

Software Engineer, Trainer, Author and Conference Speaker, interested in deep dive performance issues, PhD, Londoner.

More from the author
Java: JSON Fundamentals
Beginner
2h 29m
30 Jul 2018
Java Interfaces and Abstraction
Intermediate
1h 58m
1 Sep 2017
Understanding and Solving Java Memory Problems
Intermediate
2h 40m
28 Mar 2017
More courses by Richard Warburton
Section Introduction Transcripts
Section Introduction Transcripts

What Are Collections and Why Use Them?
Hi, my name is Richard Warburton, and I'm here to teach this course on the Java Collections Framework. The Java Collections Framework is a fundamental and essential topic in becoming a really strong Java developer, and that's why I'm so excited to be teaching this course. I'm really hopeful that whoever is taking this course, no matter whether you're a beginner or already a fairly experienced Java developer, can always take something away from it and improve themselves and learn something new. Before we go on to talk in too much detail about collections, what are they? The first thing that comes to my mind when I think about collections is this bag of roman coins, this collection of old, ancient Roman coins. You can see all of the faces on there. Some of them are happy, some of them are sad, some of them are just plain ugly if we're being honest. But if we think about what our ancient Roman would do if they had this set of coins, they would take them, and they'd put them into a little pouch or a little bag, and that pouch or bag is the collection equivalent in this Roman coin analogy. The collection is like a little container that can have 0, 1, or many elements in. That's fantastic, you say? Well hang on a minute, in Java we already have a thing that has 0, 1 or many elements in, it's called an array, and it's built into the language, so why can't we just use arrays to solve all of our data structure or all of our collection problems, and not have another new thing to learn?

Defining and Iterating Collections
Hello, Richard Warburton here. In this module we're going to talk about defining and iterating collections. And what that means is that we're going to talk about all the different things that are the background, all the common characteristics that different collections classes have. First we're going to look at our collection of collections, in other words we're going to look at what different types of collections we have, what we might want to use them for, and what makes them distinct from each other. Then we're going to brush on the distinction between the interface and the implementation, not in general object-oriented programming terms, but specifically when looking at collections. We'll recognize that there's an interface that defines the behavior of each different types of collection, and there are one or more implementations of that interface that have different performance characteristics. And as we look through each of the subsequent modules throughout this course, we're going to separate off the general behavior and then look at the different performance characteristics in turn. And finally, we're going to have a little bit of code going through what we can do with collections, we can define them, we can iterate them, those kind of common coding characteristics and practices which apply to all our different collections.

Collections with Iteration Order: Lists
Hi, Richard Warburton here. This module is called Collections with Iteration Order, and we're going to be talking about the Java. util list interface and we're going to be talking about the two classes in the core libraries that implement it, Java. util ArrayList and Java. util LinkedList. We are going to be looking at basically three different topics in this module. The first one is what are the key features of the list, what makes a list stand out from other collections, what makes it distinct from something like a set, for example? And we're also going to look at one of the API methods that a list has as we go through the key features. Then we're going to work through an example of building a Shipment class. So a Shipment class is where we've got a bunch of products that someone has ordered on a website, and we're going to have to ship them to customers, and we're going to be able to sort list elements and do a few things with them in our Shipment example. Finally, we're going to look at the different implementations of the list interface, ArrayList and LinkedList, and we're going to talk about the different performance characteristics they have, how they work under the hood in terms of their data structures, and when you want to use one versus the other.

Collections with Modification Order: Queues, Deques, and Stacks
So this module is here to explain about collections which have a modification order: Queues, Deques, and Stacks. So if you ever heard any of those terms in Java, then we're here to explain what they're all about. Now most people really, really hate queuing, but I'm British, so I love it. In Britain we love queuing so much that even our planes like to line up on the runway in a big long queue. But don't worry, as we'll see in this module, queues are extremely useful for modeling a variety of different tasks where you want a sequence, a series of actions which are going to be performed by your code. And in fact, in this module, we won't just be looking at queues or first in, first out data structures, we shall also be looking at priority queues where the order in which elements come out of the queue is defined by you, the user, and stacks or last in, first out data structures. And also we'll be talking about how a double-ended queue, or deque, can offer us abstraction which allows us to implement both stacks or queues. We shall talk about the different implementations that we have available in the Java core libraries for both the queue and deque interfaces. I hope you're looking forward to this, because I'm looking forward to teaching it.

Collection Operations
Welcome to the Collection Operations module. This is the final module of this course on the Java Collections Framework, so if you've made it this far, hello, welcome, thank you very much for making it this far. And what this module is about is common operations that we can perform on any type of collection, and in fact these operations are available on the class called java. util. Collections with an s. There are actually three different type of operations here which we're going to break things down into. Firstly there's some different algorithms that are implemented across all these collections such as sorting, shuffling, rotating, all that kind of thing. Then we're going to have a look at just some different factories, so these are methods which create new collection instances, such as empty lists and sets, or views around collections. And finally, there's a couple of just convenient utility methods which I've been avoiding using this entire time in all my examples just to make things easier for you guys, which if you're actually using collections they might be quite nice conveniences for you to use. So, to begin with, let's talk about some algorithms.