Errors and collections

Exceptions, lists and maps, and sets, queues and stacks.

About 5 hours of study

Learning objectives

Lessons

  1. 1

    Exceptions Intermediate

    How Java reports errors with exceptions: try, catch and finally, checked and unchecked exceptions, throwing your own, declaring them with throws, and the common runtime exceptions.

  2. 2

    Lists and maps Intermediate

    The two collections Java programs use most: ArrayList for ordered lists that grow, and HashMap and TreeMap for looking values up by key, with generics, wrapper types and iteration.

  3. 3

    Sets, queues and stacks Intermediate

    Collections for uniqueness and order of processing: HashSet, TreeSet and LinkedHashSet, queues and stacks with ArrayDeque, PriorityQueue, and how equals and hashCode decide what counts as the same.

Module practice

Module quiz

1. Which block always runs after try?
2. Which collection keeps items in order and allows duplicates?
3. Which order does a queue follow?
4. What must a method do with a checked exception it may throw?
5. What does map.getOrDefault(key, 0) return for a missing key?
6. Why remove items through an Iterator rather than in a for-each loop?

‹ Object-oriented JavaModern Java ›