Java in a Nutshell, 8th Edition Benjamin J. Evans pdf download
Java in a Nutshell, 8th Edition Benjamin J. Evans pdf download
https://ebookmeta.com/product/java-in-a-nutshell-8th-edition-
benjamin-j-evans/
https://ebookmeta.com/product/java-in-a-nutshell-8th-edition-
third-early-release-benjamin-j-evans/
https://ebookmeta.com/product/java-in-a-nutshell-a-desktop-quick-
reference-benjamin-j-evans/
https://ebookmeta.com/product/java-in-a-nutshell-a-desktop-quick-
reference-benjamin-evans/
https://ebookmeta.com/product/breaking-1st-edition-amanda-
cassidy/
Only Sinners Trinity Security Solutions 3 1st Edition
Tory Palmer
https://ebookmeta.com/product/only-sinners-trinity-security-
solutions-3-1st-edition-tory-palmer/
https://ebookmeta.com/product/the-jet-engine-rolls-royce/
https://ebookmeta.com/product/essentials-of-economics-5th-
edition-2022-r-glenn-hubbard/
https://ebookmeta.com/product/ships-of-the-royal-navy-5th-
edition-the-complete-record-of-all-fighting-ships-of-the-royal-
navy-from-the-15th-century-to-the-present-colledge/
Taxonomic Studies on the Genus Lasianthus Jack
Rubiaceae Collected Works ■■
https://ebookmeta.com/product/taxonomic-studies-on-the-genus-
lasianthus-jack-rubiaceae-collected-works-%e6%9c%b1%e5%8d%8e/
8t ove
C
h rs J
Ed a
Java
iti va 1
on 7
in a Nutshell
A Desktop Quick Reference
Compliments of
Benjamin J. Evans,
Jason Clark &
David Flanagan
Java in a Nutshell
The updated edition of this Nutshell guide helps
experienced Java programmers get the most out “This is a must-have
of versions through Java 17 and serves as a learning
book for developers to
path for new developers. Chock-full of examples
get a clear picture of
that demonstrate how to take complete advantage
how Java works and
of modern Java APIs and development best
practices, this thoroughly revised book includes how it has evolved over
new material on recent enhancements to the Java the years.”
object model that every developer should know. —Achyut Madhusudan
Software Developer at RedHat
The first section provides a fast-paced, no-fluff
introduction to the Java programming language
and the core runtime aspects of the Java platform. Ben Evans is a Java Champion and
The second section is a core concept and API senior principal software engineer
reference that explains how to perform real at Red Hat. Cofounder of jClarity,
he’s also served as lead architect
programming work with Java.
for instrumentation at New Relic.
• Get up to speed on language and core library Jason Clark, a principal engineer
details through Java 17 and architect at New Relic,
• Learn Java’s syntax and model for has worked on everything
from petabyte-scale JVM data
object-oriented programming processing pipelines to Ruby
• Explore generics, enumerations, instrumentation libraries.
annotations, and lambda expressions David Flanagan is a computer
• Examine how concurrency and memory programmer who spends most of
his time writing about JavaScript
are intertwined
and Java. He’s also the author of
• Delve into Java’s latest I/O APIs, including JavaScript: The Definitive Guide.
asynchronous channels
• Become familiar with development tools
in OpenJDK
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Java in a Nutshell, the cover
image, and related trade dress are trademarks of O’Reilly Media, Inc.
The views expressed in this work are those of the authors, and do not represent the publisher’s
views. While the publisher and the authors have used good faith efforts to ensure that
the information and instructions contained in this work are accurate, the publisher and
the authors disclaim all responsibility for errors or omissions, including without limitation
responsibility for damages resulting from the use of or reliance on this work. Use of the
information and instructions contained in this work is at your own risk. If any code samples
or other technology this work contains or describes is subject to open source licenses or the
intellectual property rights of others, it is your responsibility to ensure that your use thereof
complies with such licenses and/or rights.
This work is part of a collaboration between O’Reilly and Red Hat. See our statement of
editorial independence.
978-1-098-13100-5
[LSI]
This book is dedicated to all who teach peace and resist violence.
Table of Contents
Foreword. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
v
3. Object-Oriented Programming in Java. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Overview of Classes and Records 107
Fields and Methods 111
Creating and Initializing Objects 117
Subclasses and Inheritance 122
Data Hiding and Encapsulation 135
Abstract Classes and Methods 143
Modifier Summary 148
Summary 150
vi | Table of Contents
6. Java’s Approach to Memory and Concurrency. . . . . . . . . . . . . . . . . . . . . . . . . 237
Basic Concepts of Java Memory Management 237
How the JVM Optimizes Garbage Collection 241
The HotSpot Heap 243
Finalization 248
Java’s Support for Concurrency 249
Working with Threads 261
Summary 263
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
ix
Once again, in working on this new edition of a classic text, if we have preserved
the feel of Java in a Nutshell, while updating it to bring it to the attention of a new
generation of developers, then we shall be well satisfied.
—Ben Evans,
Barcelona, Spain, 2022
Jason Clark, Portland, Oregon
(& Barcelona, Spain), 2022
x | Foreword
Preface
This book is a desktop Java reference, designed to sit faithfully by your keyboard
while you program. Part I, “Introducing Java” is a fast-paced, “no-fluff ” introduc‐
tion to the Java programming language and the core runtime aspects of the Java
platform. Part II, “Working with the Java Platform” is a reference section that blends
elucidation of core concepts with examples of important core APIs. The book covers
Java 17, but we recognize that some shops may not have adopted it yet—so where
possible we call out if a feature was introduced after Java 8. We use Java 17 syntax
throughout, including var and lambda expressions.
xi
Contents of This Book
The first six chapters document the Java language and the Java platform—they
should all be considered essential reading. The book is biased toward the Ora‐
cle/OpenJDK (Open Java Development Kit) implementation of Java but not greatly
so. Developers working with other Java environments will still find plenty to occupy
them. Part I includes:
Chapter 1, “Introduction to the Java Environment”
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.
Chapter 2, “Java Syntax from the Ground Up”
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 an introduc‐
tory text (such as O’Reilly’s Head First Java by Kathy Sierra, Bert Bates, and
Trisha Gee).
Chapter 3, “Object-Oriented Programming in Java”
This chapter describes how the basic Java syntax documented in Chapter 2 is
used to write simple object-oriented programs using classes and objects in Java.
The chapter assumes no prior experience with object-oriented programming. It
can be used as a tutorial by new programmers or as a reference by experienced
Java programmers.
Chapter 4, “The Java Type System”
This chapter builds on the basic description of object-oriented programming
in Java and introduces the other aspects of Java’s type system, such as generic
types, enumerated types, and annotations. With this more complete picture, we
can discuss the biggest change in Java 8—the arrival of lambda expressions.
Chapter 5, “Introduction to Object-Oriented Design in Java”
This chapter is an overview of some basic techniques used in the design of
sound object-oriented programs, and it briefly touches on the topic of design
patterns and their use in software engineering.
Chapter 6, “Java’s Approach to Memory and Concurrency”
This chapter explains how the Java Virtual Machine manages memory on
behalf of the programmer, and how memory and visibility are intimately
entwined with Java’s support for concurrent programming and threads.
xii | Preface
These first six chapters teach you the Java language and get you up and running
with the most important concepts of the Java platform. Part II is all about how
to get real programming work done in the Java environment. It contains plenty of
examples and is designed to complement the cookbook approach found in some
other texts. This part includes:
Chapter 7, “Programming and Documentation Conventions”
This chapter documents important and widely adopted Java programming
conventions. It also explains how you can make your Java code self-
documenting by including specially formatted documentation comments.
Chapter 8, “Working with Java Collections”
This chapter introduces Java’s standard collections libraries. These contain data
structures that are vital to the functioning of virtually every Java program—
such as List, Map, and Set. The new Stream abstraction and the relationship
between lambda expressions and the collections are explained in detail.
Chapter 9, “Handling Common Data Formats”
This chapter discusses how to use Java to work effectively with very common
data formats, such as text, numbers, and temporal (date and time) information.
Chapter 10, “File Handling and I/O”
This chapter covers several different approaches to file access—from the more
classic approach found in older versions of Java, to more modern and even
asynchronous styles. The chapter concludes with a short introduction to net‐
working with the core Java platform APIs.
Chapter 11, “Classloading, Reflection, and Method Handles”
This chapter introduces the subtle art of metaprogramming in Java—first intro‐
ducing the concept of metadata about Java types, then turning to the subject
of classloading and how Java’s security model is linked to the dynamic loading
of types. The chapter concludes with some applications of classloading and the
relatively new feature of method handles.
Chapter 12, “Java Platform Modules”
This chapter describes Java Platform Module System (JPMS), the major feature
that was introduced as part of Java 9, and provides an introduction to the
wide-ranging changes that it brings.
Chapter 13, “Platform Tools”
Oracle’s JDK (as well as OpenJDK) includes a number of useful Java devel‐
opment tools, most notably the Java interpreter and the Java compiler. This
chapter documents those tools, as well as the jshell interactive environment
and new tools for working with modular Java.
Appendix
This appendix covers Java beyond version 17, including the releases Java 18
and 19 as well as ongoing research and development projects to enhance the
language and JVM.
xiii | Preface
Exploring the Variety of Random
Documents with Different Content
lähettiläittensä, avulla maailman sopusoinnun ja antanut tuolle
sopusointuiselle kokonaisuudelle kauniin, suuren nimen Kosmos.
Minä olin sanalla sanoen teosoofi.
Illuminaatti hymyili.
— Minä tiedän sen, sillä minä itse olen ne tapahtumat valmistanut.
Vanha, arka, turmeltunut kuningas, joka kuitenkin on vähemmässä
määrin raihnas kuin se yksinvalta, jota hän edustaa, määräilee
Ranskan valtaistuimella. Ainoastaan muutamia vuosia on hänellä
enää elettävänä. Meidän täytyy valmistaa parhaamme mukaan
tulevaisuutta hänen kuolinpäiväkseen. Ranska on tuon vanhan
rakennuksen kulmakivi. Tempaiskoot nuo kuusi miljoonaa kättä,
jotka kohoavat ylimmäisen piirin antamasta merkistä, pois tämän
kiven, niin yksinvaltaisuuden rakennus romahtaa maahan. Ja sinä
päivänä, jolloin tiedetään, että Ranskassa ei ole enää kuningasta,
alkaa niidenkin Euroopan yksinvaltiasten päätä huimata, jotka
kantavat kopeimpina kruunuaan, ja he heittäytyvät itsestään tuohon
kuiluun, jonka Ludvig Pyhän valtaistuin on sortuessaan avannut.
— Nyt, veljet, nyt, kun minä karkaan jalopeuran kimppuun itse sen
luolassa, — nyt, kun lähden omistamaan henkeni maailman
vapauden hyväksi, mitä teette te osaltanne asian puolesta, jolle me
olemme omistaneet henkemme, omaisuutemme ja vapautemme?
Mitä te aiotte tehdä? Sanokaa! Kas sitä olen tullut teiltä kysymään.
Suurkopti sanoi:
1.
Rajuilma.
Ilma oli ollut kello kolmeen saakka kirkas ja lämmin, mutta tuli nyt
illansuussa painostavaksi. Etelästä päin nousi valkea pilvi, joka näytti
ajavan ajoneuvoja oikein vasiten takaa ja uhkasi saada ne kiinni
ennenkuin oli päästy Bar-le-Duciin, jonne kyytimiehet ehdottivat joka
tapauksessa pysähdyttäväksi yötä viettämään.