Running on Java 22-ea+27-2262 (Preview)
Home of The JavaSpecialists' Newsletter

Data Structures in Java Course

Become a master of the full set of data structures in the Java Development Kit

Using Java 11

Duration of 1 Day


Java comes equipped with Collection, Map, List, Queue, Deque, BlockingQueue, Deque, Iterator and Iterable. And those are just some of the interfaces. We have a bunch of abstract classes, plus the implementations that we all know and love: HashMap and ArrayList.

In this one-day course, we explore all the interfaces and classes that Java offers in the latest JDK collection framework. At the end, you will have a much better idea of what collections to use when. You will also know how to write your own collections.

Here are some of the many things we will cover during this workshop:

  • Memory footprint of various collections
  • Computational time complexity of lookups and other operations
  • When to use LinkedList vs ArrayList vs CopyOnWriteArrayList
  • How HashMap behaves with bad keys
  • Speeding up hashing by 3x for modern Java versions
  • How biased locking affects our collection choices from Java 15 onwards
  • UnsupportedOperationException
  • How ConcurrentModificationException came about and what to do about it
  • Good techniques for measuring costs of collections
  • Converting Maps to Sets
  • Compound operations on Maps
  • WeakHashMap, LinkedHashMap, LinkedHashSet, IdentityHashSet, ConcurrentSkipListSet and other collections we hardly use.

Course Format

Most of our courses give students a lot of exercises. This course is different. We have an outline of what we want to cover, but then it is the author of the course demonstrating the various data structures and the students able to ask questions. There are no "slides" as such, everything is in code. At the end of the course, you will get a complete source repository of all the examples that we coded during class. Even though there are no exercises, students are encouraged to follow along in their IDE and try out the ideas that the instructor is demonstrating.

Who should take this course?

This course is aimed at junior to intermediate Java programmers wanting to learn what Java data structures are available and how to best use them.

Data Structures in Java Course Enquiry


Prerequisites

This course is aimed at junior to intermediate Java programmers wanting to learn what Java data structures are available and how to best use them.

Pricing Options

We have several options for you to join this course:

1. Virtual In-house Course:

Presented via video conference to your team of programmers by the author of the course. Price is €2976 for up to 10 students, above that is an additional €270 per student.

  • Example 1: Course with 8 students taught remotely via video conference, price is €2976. Price per student is €372.
  • Example 2: Course with 12 students taught remotely via video conference, price is €3516. Price per student is €293.
  • Example 3: Course with 24 students taught remotely via video conference, price is €6756. Price per student is €281.

Please contact us if you have any questions.

2. In-person In-house Course:

Presented at your company in-person by one of our Certified JavaSpecialist Instructors. Price is €4380 for up to 10 students, above that is an additional €400 per student, plus the travel expenses of the instructor. Note that for in-person in-house courses, we need a minimum of three consecutive training days.

  • Example 1: Course with 8 students taught on-site at your company, price is €4380. Price per student is €547.
  • Example 2: Course with 12 students taught on-site at your company, price is €5180. Price per student is €431.
  • Example 3: Course with 18 students taught on-site at your company, price is €7580. Price per student is €421.

Please contact us if you have any questions.

2. Open Enrollment Classroom Course:

We occasionally offer this course as a classroom course in Chania on the Island of Crete. Price for the course is €949 per student.

We also offer this course as an open enrollment live remote course that you can attend from anywhere. Price is €649 per student.

Please contact us if you have would like to make a booking or if you have any questions.

4. Self-Paced Course:

This course is also available as a self-paced course.

Please contact us if you have any questions.

* Prices exclude EU VAT and withholding taxes where applicable. Please contact us for an exact quote for your country.

Open Courses

All our courses are offered as in-house courses. Please contact us on heinz@javaspecialists.eu.

* Price is excluding EU VAT where applicable. Please contact us for an exact quote for your country.

Detailed Outline

The emphasis of this training workshop is to learn what data structures modern Java has to offer. Here is our outline:

  • 0. Welcome
  • 1. Introduction to Collections in Java
    • Computational Time and Space Complexity
      • O(1), O(n), O(n2), O(log n), O(n * log n)
    • Arrays
      • Primitive vs object arrays
      • Memory usage and layout
      • Multi-dimensional arrays
  • 2. Lists
    • Lists
      • Arrays.asList()
      • Quick look at the List methods
      • Optional methods
        • asList() vs List.of()
      • RandomAccess
    • ArrayList
      • Adding four seasons
      • indexOf() and contains()
      • size() vs elementData.length in debugger
      • removeIf()
    • Iteration
      • Enumeration bugs
      • Fail fast collection
      • forEach()
    • CopyOnWriteArrayList
      • Safe iteration
    • LinkedList
      • Node memory usage
      • Accessing middle of list
  • 3. Sorting
    • Sorting lists
      • Sorting list of Strings
      • Sorting custom classes like Student
        • Comparing ints and longs
      • Writing Comparators as anonymous classes
      • Comparators with extractor functions
        • Type witnesses
        • Declared lambda parameters
        • Method references
      • Sorting performance ArrayList vs LinkedList
        • Parallel sorting of ArrayList
  • 4. Sets
    • Sets
      • Set.of()
      • union with addAll()
      • intersection with retainAll() or stream/filter
    • TreeSet
      • Sorted by natural order
      • Red-black tree
        • Unbalanced tree O(n) vs O(log n)
        • Counting maximum tree depth
    • ConcurrentSkipListSet
      • Thread-safe sorted set
    • CopyOnWriteArraySet
      • For very small sets
  • 5. Hashing
    • Hashing
      • Writing very basic hashtable
      • Clashes and distribution
      • % vs &
    • HashSet
      • hashCode() vs identityHashCode()
      • Pixel and good hash code
      • Bucket collisions
      • Making keys implement Comparable
    • ConcurrentHashMap.newKeySet()
  • 6. Maps
    • Maps
      • one-to-one dictionary
    • HashMap
      • History of hashing 1.2, 1.4, 1.8+
      • Building a hash code with bit shifting Person(name,day,month,year)
      • Cached hash code in Strings
      • MapClashInspector
      • Creating maps of numbers
        • computeIfAbsent() for List of values
    • ConcurrentHashMap
      • Always use
      • Compound operations review
    • TreeMap
      • hashCode(), equals() and compareTo()
      • Own Comparator
    • ConcurrentSkipListMap
      • Parallel put into TreeMap vs ConcurrentSkipListMap
    • LinkedHashMap and LinkedHashSet
    • Highly Specialized Collections: EnumSet, EnumMap, IdentityHashMap, Properties, WeakHashMap
  • 7 - Queues and Deques
    • Queues and Deques
      • Not always FIFO
    • ConcurrentLinkedQueue and ConcurrentLinkedDeque
      • General purpose MPMC queues
      • size() is O(n)
    • ArrayDeque
      • Grows, does not shrink
    • BlockingQueues
    • LinkedBlockingQueue and LinkedBlockingDeque
      • Lock splitting
    • ArrayBlockingQueue
      • Compact array structure
    • Highly specialized queues: DelayQueue, SynchronousQueue, LinkedTransferQueue, PriorityQueue and PriorityBlockingQueue
  • 8 - Collection Facades
    • java.util.Collections
    • java.util.Arrays
  • 9 - Wrap-up

About the Author

Heinz Kabutz Java Conference Speaker

Java Champion, author of the Javaspecialists Newsletter, conference speaking regular... About Heinz

Superpack '23

Superpack '23 Our entire Java Specialists Training in one huge bundle more...

Free Java Book

Dynamic Proxies in Java Book

110% Money-back Guarantee

Should you not be satisfied with the quality of the training or the delivery, we will gladly refund you 100% of the course fees. This needs to be brought to our attention within the first 4 hours of the course and a chance should be given to correct whatever you are not satisfied with. If you are still not satisfied, we will refund you 100% of the course fees, plus we will pay our own travel expenses. The training material then remains the property of JavaSpecialists.EU.


Cancellation Policy

If the course is cancelled more than two weeks before the start of the course, a 10% cancellation fee of the fees will apply, plus any non-refundable travel expenses incurred by the trainer.

If the course is cancelled within two weeks of the start of the course, a 50% cancellation fee of the fees will apply, plus any non-refundable travel expenses incurred by the trainer.

No refund will be given to cancellations during the course.


Java Training

We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.

Java Consulting

We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...