Java in a Nutshell: A Desktop Quick Reference, 8th Edition
- Length: 470 pages
- Edition: 8
- Language: English
- Publisher: O'Reilly Media
- Publication Date: 2023-03-28
- ISBN-10: 1098131002
- ISBN-13: 9781098131005
- Sales Rank: #3194901 (See Top 100 Books)
This updated edition of the Nutshell guide not only helps experienced Java programmers get the most out of versions through Java 17, it also serves as 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 recent enhancements to the Java object model that every developer should know about.
The 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 through Java 17
- Learn object-oriented programming using basic Java syntax
- Explore generics, enumerations, annotations, and lambda expressions
- Understand techniques used in object-oriented design
- Examine how concurrency and memory are intertwined
- Work with Java collections and handle common data formats
- Delve into Java’s latest I/O APIs including asynchronous channels
- Become familiar with development tools in OpenJDK
Foreword Preface Changes in the Eighth Edition Contents of This Book Related Books Conventions Used in This Book Using Code Examples O’Reilly Online Learning How to Contact Us Acknowledgments I. Introducing Java 1. Introduction to the Java Environment The Language, the JVM, and the Ecosystem What Is the Java Language? What Is the JVM? What Is the Java Ecosystem? The Lifecycle of a Java Program Frequently Asked Questions What is a virtual machine? What is bytecode? Is javac a compiler? Why is it called “bytecode”? Is bytecode optimized? Is bytecode really machine independent? What about things like endianness? Is Java an interpreted language? Can other languages run on the JVM? Comparing Java to Other Languages Java Compared to JavaScript Java Compared to Python Java Compared to C Java Compared to C++ Answering Some Criticisms of Java Overly Verbose Slow to Change Performance Problems Insecure Too Corporate A Brief History of Java and the JVM Summary 2. Java Syntax from the Ground Up Java Programs from the Top Down Lexical Structure The Unicode Character Set Case Sensitivity and Whitespace Comments Reserved Words Identifiers Literals Punctuation Primitive Data Types The boolean Type The char Type String literals Integer Types Floating-Point Types Primitive Type Conversions Expressions and Operators Operator Summary Precedence Associativity Operator summary table Operand number and type Return type Side effects Order of evaluation Arithmetic Operators String Concatenation Operator Increment and Decrement Operators Comparison Operators Boolean Operators Bitwise and Shift Operators Assignment Operators The Conditional Operator The instanceof Operator Special Operators Statements Expression Statements Compound Statements The Empty Statement Labeled Statements Local Variable Declaration Statements The if/else Statement The else if clause The switch Statement The switch Expression The while Statement The do Statement The for Statement The foreach Statement What foreach cannot do The break Statement The continue Statement The return Statement The synchronized Statement The throw Statement The try/catch/finally Statement try catch finally The try-with-resources Statement The assert Statement Enabling assertions Methods Defining Methods Method Modifiers Checked and Unchecked Exceptions Working with checked exceptions Variable-Length Argument Lists Introduction to Classes and Objects Defining a Class Creating an Object Using an Object Object Literals String literals Type literals The null reference Lambda Expressions Arrays Array Types Array type widening conversions C compatibility syntax Creating and Initializing Arrays Array initializers Using Arrays Accessing array elements Array bounds Iterating arrays Copying arrays Array utilities Multidimensional Arrays Reference Types Reference Versus Primitive Types Manipulating Objects and Reference Copies Comparing Objects Boxing and Unboxing Conversions Packages and the Java Namespace Package Declaration Globally Unique Package Names Importing Types Naming conflicts and shadowing Importing Static Members Static member imports and overloaded methods Java Source File Structure Defining and Running Java Programs Summary 3. Object-Oriented Programming in Java Overview of Classes and Records Basic OO Definitions Records Other Reference Types Class Definition Syntax Fields and Methods Field Declaration Syntax Class Fields Class Methods Instance Fields Instance Methods How the this Reference Works Creating and Initializing Objects Defining a Constructor Defining Multiple Constructors Invoking One Constructor from Another Field Defaults and Initializers Initializer blocks Record Constructors Subclasses and Inheritance Extending a Class Final classes Superclasses, Object, and the Class Hierarchy Subclass Constructors Constructor Chaining and the Default Constructor The default constructor Hiding Superclass Fields Overriding Superclass Methods Overriding is not hiding Virtual method lookup Invoking an overridden method Sealed Classes Data Hiding and Encapsulation Access Control Access to modules Access to packages Access to classes Access to members Access control and inheritance Member access summary Data Accessor Methods Abstract Classes and Methods Reference Type Conversions Modifier Summary Summary 4. The Java Type System Interfaces Defining an Interface Extending Interfaces Implementing an Interface Records and Interfaces Sealed Interfaces Default Methods Backward compatibility Implementation of default methods Marker Interfaces Java Generics Introduction to Generics Generic Types and Type Parameters Diamond Syntax Type Erasure Bounded Type Parameters Introducing Covariance Wildcards Bounded wildcards Generic Methods Compile and Runtime Typing Using and Designing Generic Types Enums and Annotations Enums Annotations Defining Custom Annotations Type Annotations Lambda Expressions Lambda Expression Conversion Method References Functional Programming Lexical Scoping and Local Variables Nested Types Static Member Types Features of static member types Nonstatic Member Classes Features of member classes Syntax for member classes Local Classes Features of local classes Scope of a local class Anonymous Classes Describing the Java Type System Nominal Typing Nondenotable Types and var Summary 5. Introduction to Object-Oriented Design in Java Java Values Important Common Methods toString() equals() hashCode() Comparable::compareTo() clone() Constants Working with Fields Field Inheritance and Accessors Singleton Factory Methods Builders Interfaces Versus Abstract Classes Do Default Methods Change Java’s Inheritance Model? OOD Using Lambdas Lambdas Versus Nested Classes Lambdas Versus Method References OOD Using Sealed Types OOD Using Records Instance Methods or Class Methods? A word about System.out.println() Composition Versus Inheritance Exceptions and Exception Handling Safe Java Programming 6. Java’s Approach to Memory and Concurrency Basic Concepts of Java Memory Management Memory Leaks in Java Introducing Mark-and-Sweep How the JVM Optimizes Garbage Collection Evacuation Compaction The HotSpot Heap G1 ParallelOld Serial Shenandoah ZGC Finalization Finalization Details Java’s Support for Concurrency Thread Lifecycle Visibility and Mutability Concurrent safety Exclusion and Protecting State volatile Useful Methods of Thread getId() getPriority() and setPriority() setName() and getName() getState() isAlive() start() interrupt() join() setDaemon() setUncaughtExceptionHandler() Deprecated Methods of Thread stop() suspend(), resume(), and countStackFrames() destroy() Working with Threads Summary II. Working with the Java Platform 7. Programming and Documentation Conventions Naming and Capitalization Conventions Practical Naming Java Documentation Comments Structure of a Doc Comment Doc-Comment Tags Inline Doc-Comment Tags Cross-References in Doc Comments Doc Comments for Packages Doclets Conventions for Portable Programs Summary 8. Working with Java Collections Introduction to Collections API The Collection Interface The Set Interface The List Interface Foreach loops and iteration Random access to Lists The Map Interface The Queue and BlockingQueue Interfaces Adding Elements to Queues Removing Elements from Queues Querying Utility Methods Special-case collections Arrays and Helper Methods Java Streams and Lambda Expressions Functional Approaches Filter Map forEach Reduce The Streams API Lazy evaluation Further filtering Matching in streams Flattening From Streams to Collections From Streams to values Streams utility default methods Summary 9. Handling Common Data Formats Text Special Syntax for Strings String literals toString() String concatenation String Immutability Hash codes and effective immutability String Formatting Regular Expressions Numbers and Math How Java Represents Integer Types Java and Floating-Point Numbers BigDecimal Java’s Standard Library of Mathematical Functions Date and Time Introducing the Java 8 Date and Time API The parts of a timestamp Example Queries Adjusters Timezones Legacy Date and Time Summary 10. File Handling and I/O Classic Java I/O Files I/O Streams Readers and Writers try-with-resources Revisited Problems with Classic I/O Modern Java I/O Files Path NIO Channels and Buffers ByteBuffer Mapped Byte Buffers Async I/O Future-Based Style Callback-Based Style Watch Services and Directory Searching Networking HTTP TCP IP Summary 11. Classloading, Reflection, and Method Handles Class Files, Class Objects, and Metadata Examples of Class Objects Class Objects and Metadata Phases of Classloading Loading Verification Preparation and Resolution Initialization Secure Programming and Classloading Applied Classloading Classloader Hierarchy Bootstrap classloader Platform classloader Application classloader Custom classloader Reflection When to Use Reflection How to Use Reflection Method objects Creating instances with Reflection Problems with Reflection Dynamic Proxies Method Handles MethodType Method Lookup Invoking Method Handles 12. Java Platform Modules Why Modules? Modularizing the JDK Writing Your Own Modules Basic Modules Syntax Building a Simple Modular Application The Module Path Automatic Modules Open Modules Providing Services Multi-Release JARs Converting to a Multi-Release JAR Migrating to Modules Custom Runtime Images Issues with Modules Unsafe and Related Problems Lack of Versioning Slow Adoption Rates Summary 13. Platform Tools Command-Line Tools Introduction to JShell Introduction to Java Flight Recorder (JFR) Summary A. Beyond Java 17 Long-Term JDK Projects Amber Java 18 Panama Java 19 Loom Future Java Valhalla Cloud-Native Java Index
Donate to keep this site alive
How to download source code?
1. Go to: https://www.oreilly.com/
2. Search the book title: Java in a Nutshell: A Desktop Quick Reference, 8th Edition
, sometime you may not get the results, please search the main title
3. Click the book title in the search results
3. Publisher resources
section, click Download Example Code
.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.