O'Reilly logo

OCP Oracle® Certified Professional Java® SE 8 Programmer II by Scott Selikoff, Jeanne Boyarsky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3 Generics and Collections

THE OCP EXAM TOPICS COVERED IN THIS CHAPTER INCLUDE THE FOLLOWING:

  • ✓  Generics and Collections
    • Create and use a generic class
    • Create and use ArrayList, TreeSet, TreeMap and ArrayDeque objects
    • Use java.util.Comparator and java.lang.Comparable interfaces
    • Iterate using forEach methods on Streams and List
    • Use method references with Streams
  • ✓  Advanced Java Class Design
    • Create and use lambda expressions
  • ✓  Generics and Collections
    • Filter a collection using lambda expressions
  • ✓  Java Stream API
    • Use of merge()and flatMap()methods of the Stream API

images

You learned about ArrayList on the OCA. This chapter covers the rest of the Java Collections Framework that you need to know for the exam. This includes other lists, sets, queues, and maps. The thread-safe collection types will be discussed in Chapter 7, “Concurrency.”

We will also discuss how to create your own classes and methods that use generics so that the same class can be used with many types. You’ll learn how to customize searching and sorting using Comparable and Comparator. We will end with some methods that use functional interfaces, such as forEach() and merge().

In the next chapter, we will cover the Stream API. Note that the exam objectives are sloppy and sometimes use “stream” to include “stream” and “lambda.” The merge() method is on Map and not really a stream API.

Reviewing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required