This book is a desktop Java reference, designed to sit faithfully by your keyboard while you program. is a reference section that blends elucidation of core concepts with examples of important core APIs. The book covers Java 8, but we recognize that some shops may not have adopted it yetso where possible we call out if a feature was introduced in Java 8 (and sometimes Java 7). We use Java 8 syntax throughout, including using lambda expressions in code that would previously have used a trivial anonymous nested class.
Changes in the Sixth Edition
The fifth edition of this book covers Java 5, whereas this edition covers Java 8. The language, and the working environment of the programmer, have both changed considerably since the last edition was published nearly a decade ago. This new edition has, accordingly, changed a vast amount as well. One very important aspect is that this book does not attempt to be as complete a description of the core platform APIs as was possible in earlier editions.
For one thing, the sheer size of the core APIs render this utterly impractical for a printed book. A more compelling reason is the continued rise of fast, always-on Internet. The amount of Java programmers who regularly work without Internet access is now vanishingly small. The proper place for detailed reference API docs is online, not printed out.
Accordingly, the reference section, which occupied two-thirds of the fifth edition, is gone. In the space weve recovered, we have tried to update the concept of what it means to be a Nutshell guide. The modern Java developer needs to know more than just syntax and APIs. As the Java environment has matured, such topics as concurrency, object-oriented design, memory, and the Java type system have all gained in importanceeven among mainstream developers.
In this edition, we have tried to reflect this changed world, and have largely abandoned the historical approach of earlier editions. In particular, the exhaustive attempt to detail exactly which version of Java particular features arrived with has mostly been abandonedonly the most recent versions of Java are likely to be of interest to the majority of Java developers.
Contents of This Book
The first six chapters of this book document the Java language and the Java platformthey should all be considered essential reading. The book is biased toward the Oracle/OpenJDK (Open Java Development Kit) implementation of Java, but not greatly sodevelopers working with other Java environments will still find plenty to occupy them. includes:
This chapter is an overview of the Java language and the Java platform. It explains the important features and benefits of Java, including the lifecycle of a Java program. We also touch on Java security and answer some criticisms of Java.
This chapter explains the details of the Java programming language, including the Java 8 language changes. It is a long and detailed chapter that does not assume substantial programming experience. Experienced Java programmers can use it as a language reference. Programmers with substantial experience with languages such as C and C++ should be able to pick up Java syntax quickly by reading this chapter; beginning programmers with only a modest amount of experience should be able to learn Java programming by studying this chapter carefully, although it is best read in conjunction with a second text (such as OReillys Head First Java by Bert Bates and Kathy Sierra).
This chapter describes how the basic Java syntax documented in is used to write simple object-oriented programs using classes and objects in Java. The chapter assumes no prior experience with OO programming. It can be used as a tutorial by new programmers or as a reference by experienced Java programmers.
This chapter builds on the basic description of object-oriented programming in Java, and introduces the other aspects of Javas type system, such as generic types, enumerated types, and annotations. With this more complete picture, we can discuss the biggest change in Java 8the arrival of lambda expressions.