SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
The #1 Java Guide for Serious Programmers: Fully Updated through Java 17
"This is the definitive reference and instructional work for Java and the Java ecosystem."
---Andrew Binstock, Java Magazine
To access bug lists, sample code, and a List of Frequently Asked Questions, visit the author's site at horstmann.com.
Java Interfaces, Lambda Expressions, and Inner Classes
Download the sample pages (includes Chapter 6)
Preface xxi
Acknowledgments xxvii
Chapter 1: An Introduction to Java 1
1.1 Java as a Programming Platform 1
1.2 The Java "White Paper" Buzzwords 2
1.3 Java Applets and the Internet 9
1.4 A Short History of Java 10
1.5 Common Misconceptions about Java 13
Chapter 2: The Java Programming Environment 17
2.1 Installing the Java Development Kit 17
2.2 Using the Command-Line Tools 22
2.3 Using an Integrated Development Environment 27
2.4 JShell 30
Chapter 3: Fundamental Programming Structures in Java 35
3.1 A Simple Java Program 36
3.2 Comments 39
3.3 Data Types 40
3.4 Variables and Constants 46
3.5 Operators 51
3.6 Strings 61
3.7 Input and Output 76
3.8 Control Flow 85
3.9 Big Numbers 106
3.10 Arrays 109
Chapter 4: Objects and Classes 125
4.1 Introduction to Object-Oriented Programming 126
4.2 Using Predefined Classes 132
4.3 Defining Your Own Classes 141
4.4 Static Fields and Methods 156
4.5 Method Parameters 163
4.6 Object Construction 170
4.7 Records 181
4.8 Packages 186
4.9 JAR Files 198
4.10 Documentation Comments 204
4.11 Class Design Hints 210
Chapter 5: Inheritance 213
5.1 Classes, Superclasses, and Subclasses 214
5.2 Object: The Cosmic Superclass 235
5.3 Generic Array Lists 251
5.4 Object Wrappers and Autoboxing 259
5.5 Methods with a Variable Number of Parameters 263
5.6 Abstract Classes 265
5.7 Enumeration Classes 271
5.8 Sealed Classes 273
5.9 Reflection 279
5.10 Design Hints for Inheritance 308
Chapter 6: Interfaces, Lambda Expressions, and Inner Classes 311
6.1 Interfaces 312
6.2 Lambda Expressions 338
6.3 Inner Classes 357
6.4 Service Loaders 376
6.5 Proxies 378
Chapter 7: Exceptions, Assertions, and Logging 387
7.1 Dealing with Errors 388
7.2 Catching Exceptions 397
7.3 Tips for Using Exceptions 411
7.4 Using Assertions 415
7.5 Logging 420
7.6 Debugging Tips 441
Chapter 8: Generic Programming 447
8.1 Why Generic Programming? 448
8.2 Defining a Simple Generic Class 450
8.3 Generic Methods 453
8.4 Bounds for Type Variables 454
8.5 Generic Code and the Virtual Machine 457
8.6 Restrictions and Limitations 462
8.7 Inheritance Rules for Generic Types 472
8.8 Wildcard Types 475
8.9 Reflection and Generics 483
Chapter 9: Collections 497
9.1 The Java Collections Framework 498
9.2 Interfaces in the Collections Framework 508
9.3 Concrete Collections 510
9.4 Maps 535
9.5 Copies and Views 548
9.6 Algorithms 558
9.7 Legacy Collections 569
Chapter 10: Graphical User Interface Programming 581
10.1 A History of Java User Interface Toolkits 582
10.2 Displaying Frames 583
10.3 Displaying Information in a Component 590
10.4 Event Handling 614
10.5 The Preferences API 639
Chapter 11: User Interface Components with Swing 647
11.1 Swing and the Model-View-Controller Design Pattern 648
11.2 Introduction to Layout Management 652
11.3 Text Input 658
11.4 Choice Components 667
11.5 Menus 686
11.6 Sophisticated Layout Management 705
11.7 Dialog Boxes 721
Chapter 12: Concurrency 747
12.1 What Are Threads? 748
12.2 Thread States 753
12.3 Thread Properties 757
12.4 Synchronization 764
12.5 Thread-Safe Collections 797
12.6 Tasks and Thread Pools 815
12.7 Asynchronous Computations 830
12.8 Processes 847
Appendix 855
Index 861