This updated edition of Java in a Nutshell not only helps experienced Java programmers get the most out of Java versions 9 through 11, it’s also a learning path for new developers. Chock full of examples that demonstrate how to take complete advantage of modern Java APIs and development best practices, this thoroughly revised book includes new material on Java Concurrency Utilities.
The book’s first section provides a fast-paced, no-fluff introduction to the Java programming language and the core runtime aspects of the Java platform. The second section is a reference to core concepts and APIs that explains how to perform real programming work in the Java environment.
- Get up to speed on language details, including Java 9-11 changes
- Learn object-oriented programming, using basic Java syntax
- Explore generics, enumerations, annotations, and lambda expressions
- Understand basic techniques used in object-oriented design
- Examine concurrency and memory, and how they’re intertwined
- Work with Java collections and handle common data formats
- Delve into Java’s latest I/O APIs, including asynchronous channels
- Use Nashorn to execute JavaScript on the Java Virtual Machine
- Become familiar with development tools in OpenJDK
Changes in the Seventh Edition:
The sixth edition of this book covers Java 8, whereas this edition covers Java 11. However, the release process of Java changed significantly with the advent of Java 9, so this book is released only a year after Java 9 arrived. Java 11 is also the first long-term support (LTS) release of Java since Java 8, so it seems likely that many Java shops will jump straight to Java 11 from Java 8.
With the seventh edition 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 grown in importance—even among mainstream developers.
In this edition, we have taken the approach that only the most recent versions of Java are likely to be of interest to the majority of Java developers, so we usually only call out when new features arrived if it was with Java 8 or later.
The module system (that arrived with Java 9) is still likely to be new for at least some developers, and it represents a major change.
Author(s): Benjamin J. Evans; David Flanagan
Edition: 7th
Publisher: O’Reilly Media
Year: 2019
Language: English
Commentary: True PDF
Pages: 436
Tags: Programming;Java;Software;OOP;OpenJDK;
Cover......Page 1
Table of Contents......Page 6
Foreword......Page 10
Preface......Page 12
Part I. Introducting Java......Page 18
1. Introduction to the Java Environment......Page 20
The Language, the JVM, and the Ecosystem......Page 21
A Brief History of Java and the JVM......Page 25
The Lifecycle of a Java Program......Page 27
Java Security......Page 29
Comparing Java to Other Languages......Page 30
Answering Some Criticisms of Java......Page 31
2. Java Syntax from the Ground Up......Page 36
Lexical Structure......Page 37
Primitive Data Types......Page 41
Expressions and Operators......Page 50
Statements......Page 67
Methods......Page 88
Introduction to Classes and Objects......Page 95
Arrays......Page 99
Reference Types......Page 107
Packages and the Java Namespace......Page 111
Java Source File Structure......Page 116
Summary......Page 117
Overview of Classes......Page 120
Fields and Methods......Page 123
Creating and Initializing Objects......Page 129
Subclasses and Inheritance......Page 133
Data Hiding and Encapsulation......Page 145
Abstract Classes and Methods......Page 153
Modifier Summary......Page 157
4. The Java Type System......Page 160
Interfaces......Page 161
Java Generics......Page 169
Enums and Annotations......Page 181
Lambda Expressions......Page 186
Nested Types......Page 194
Non-Denotable Types and var......Page 205
Summary......Page 206
Java Values......Page 208
Important Methods of java.lang.Object......Page 209
Aspects of Object-Oriented Design......Page 214
Object-Oriented Design with Lambdas......Page 225
Exceptions and Exception Handling......Page 228
Safe Java Programming......Page 230
Basic Concepts of Java Memory Management......Page 232
How the JVM Optimizes Garbage Collection......Page 237
The HotSpot Heap......Page 239
Finalization......Page 243
Java's Support for Concurrency......Page 246
Working with Threads......Page 257
Summary......Page 259
Part II. Working with the Java Platform......Page 260
Naming and Capitalization Conventions......Page 262
Practical Naming......Page 264
Java Documentation Comments......Page 266
Doclets......Page 274
Conventions for Portable Programs......Page 275
Introduction to Collections API......Page 278
Java Streams and Lambda Expressions......Page 300
Summary......Page 308
Text......Page 310
Numbers and Math......Page 318
Java 8 Date and Time......Page 323
Summary......Page 329
Classic Java I/O......Page 330
Modern Java I/O......Page 336
NIO Channels and Buffers......Page 340
Async I/O......Page 342
Networking......Page 345
Class Files, Class Objects, and Metadata......Page 352
Phases of Classloading......Page 354
Secure Programming and Classloading......Page 357
Applied Classloading......Page 359
Reflection......Page 362
Method Handles......Page 368
12. Java Platform Modules......Page 372
Why Modules?......Page 373
Writing Your Own Modules......Page 376
Issues with Modules......Page 386
Summary......Page 388
Command-Line Tools......Page 390
Introduction to JShell......Page 406
Summary......Page 409
A. Additional Tools......Page 410
Index......Page 432