Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan




It’s a great time to be a Java developer; Java performance continues to improve, and Java 17 is the fastest release yet.

Java in a Nutshell is the reference guide every Java developer needs at their fingertips. It’s designed to help you get the most out of versions through Java 17, with examples that show how to take advantage of modern Java APIs and development best practices.

The first part of the book provides a comprehensive overview of the Java language and the Java platform, with just enough information for new developers to get started using Java right away. Part II covers some of the core libraries that ship with Java and programming techniques that are common to intermediate and advanced Java programs. This latest edition of Java in a Nutshell also covers recent enhancements to the Java object model that every developer should know about.

  • Get up to speed on language and core library details through Java 17
  • Learn Java’s syntax and model for object-oriented programming
  • Explore generics, enumerations, annotations, and lambda expressions
  • Examine how concurrency and memory are intertwined
  • Delve into Java’s latest I/O APIs, including asynchronous channels
  • Become familiar with development tools in OpenJDK


Introduction to Collections API

The Java Collections are a set of generic interfaces that describe the most common forms of data structure. Java ships with several implementations of each of the classic data structures, and because the types are represented as interfaces, it is very possible for development teams to develop their own, specialized implementations of the interfaces for use in their own projects.

The Java Collections define two fundamental types of data structures. A Collection is a grouping of objects, while a Map is a set of mappings, or associations, between objects. The basic layout of the Java Collections is shown in Figure 8-1.

Within this basic description, a Set is a type of Collection with no duplicates, and a List is a Collection in which the elements are ordered (but may contain duplicates).

SortedSet and SortedMap are specialized sets and maps that maintain their elements in a sorted order.

Collection, Set, List, Map, SortedSet, and SortedMap are all interfaces, but the java.util package also defines various concrete implementations, such as lists based on arrays and linked lists, and maps and sets based on hash tables or binary trees. Other important interfaces are Iterator and Iterable, which allow you to loop through the objects in a collection, as we will see later on.

Related E-books