HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. 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.
Clear, Concise Guide to the Core Language and Libraries--Updated through Java 17
Modern Java introduces major enhancements that impact the core Java technologies and APIs at the heart of the Java platform. Many old Java idioms are no longer needed, and new features and programming paradigms can make you far more effective. However, navigating these changes can be challenging.
Core Java for the Impatient, Third Edition, is a complete yet concise guide that reflects all changes through Java SE 17, Oracle's latest Long-Term Support (LTS) release. Written by Cay S. Horstmann--author of the classic two-volume Core Java--this indispensable tutorial offers a faster, easier pathway for learning modern Java.
Horstmann covers everything working developers need to know, including the powerful concepts of lambda expressions and streams, modern constructs such as records and sealed classes, and sophisticated concurrent programming techniques. Given the size and scope of Java 17, there's plenty to cover, but it's presented in small chunks organized for quick access and easy understanding, with plenty of practical insights and sample code to help you quickly apply all that's new.
Whether you're an experienced developer just getting started with modern Java, or have been programming with Java for years, this guide will help you write more robust, efficient, and secure Java code.
Register your book for convenient access to downloads, updates, and/or corrections as they become available. See inside book for details.
Download the sample pages (includes Chapter 9)
Preface xxiii
Acknowledgments xxv
About the Author xxvii
Chapter 1: Fundamental Programming Structures 1
1.1 Our First Program 2
1.2 Primitive Types 11
1.3 Variables 14
1.4 Arithmetic Operations 17
1.5 Strings 25
1.6 Input and Output 35
1.7 Control Flow 38
1.8 Arrays and Array Lists 46
1.9 Functional Decomposition 56
Exercises 58
Chapter 2: Object-Oriented Programming 61
2.1 Working with Objects 62
2.2 Implementing Classes 67
2.3 Object Construction 71
2.4 Records 76
2.5 Static Variables and Methods 79
2.6 Packages 83
2.7 Nested Classes 90
2.8 Documentation Comments 95
Exercises 100
Chapter 3: Interfaces and Lambda Expressions 105
3.1 Interfaces 106
3.2 Static, Default, and Private Methods 113
3.3 Examples of Interfaces 117
3.4 Lambda Expressions 121
3.5 Method and Constructor References 124
3.6 Processing Lambda Expressions 127
3.7 Lambda Expressions and Variable Scope 131
3.8 Higher-Order Functions 135
3.9 Local and Anonymous Classes 137
Exercises 139
Chapter 4: Inheritance and Reflection 143
4.1 Extending a Class 144
4.2 Inheritance Hierarchies 150
4.3 Object: The Cosmic Superclass 157
4.4 Enumerations 166
4.5 Runtime Type Information and Resources 170
4.6 Reflection 179
Exercises 188
Chapter 5: Exceptions, Assertions, and Logging 191
5.1 Exception Handling 192
5.2 Assertions 204
5.3 Logging 206
Exercises 214
Chapter 6: Generic Programming 219
6.1 Generic Classes 220
6.2 Generic Methods 221
6.3 Type Bounds 222
6.4 Type Variance and Wildcards 223
6.5 Generics in the Java Virtual Machine 228
6.6 Restrictions on Generics 231
6.7 Reflection and Generics 238
Exercises 241
Chapter 7: Collections 247
7.1 An Overview of the Collections Framework 248
7.2 Iterators 252
7.3 Sets 254
7.4 Maps 255
7.5 Other Collections 259
7.6 Views 264
Exercises 267
Chapter 8: Streams 271
8.1 From Iterating to Stream Operations 272
8.2 Stream Creation 273
8.3 The filter, map, and flatMap Methods 276
8.4 Extracting Substreams and Combining Streams 278
8.5 Other Stream Transformations 279
8.6 Simple Reductions 280
8.7 The Optional Type 281
8.8 Collecting Results 286
8.9 Collecting into Maps 287
8.10 Grouping and Partitioning 289
8.11 Downstream Collectors 289
8.12 Reduction Operations 292
8.13 Primitive Type Streams 294
8.14 Parallel Streams 295
Exercises 298
Chapter 9: Processing Input and Output 301
9.1 Input/Output Streams, Readers, and Writers 302
9.2 Paths, Files, and Directories 312
9.3 HTTP Connections 320
9.4 Regular Expressions 323
9.5 Serialization 333
Exercises 344
Chapter 10: Concurrent Programming 347
10.1 Concurrent Tasks 348
10.2 Asynchronous Computations 353
10.3 Thread Safety 360
10.4 Parallel Algorithms 366
10.5 Threadsafe Data Structures 368
10.6 Atomic Counters and Accumulators 373
10.7 Locks and Conditions 375
10.8 Threads 381
10.9 Processes 386
Exercises 390
Chapter 11: Annotations 397
11.1 Using Annotations 398
11.2 Defining Annotations 403
11.3 Standard Annotations 406
11.4 Processing Annotations at Runtime 410
11.5 Source-Level Annotation Processing 413
Exercises 417
Chapter 12: The Date and Time API 421
12.1 The Time Line 422
12.2 Local Dates 424
12.3 Date Adjusters 428
12.4 Local Time 429
12.5 Zoned Time 430
12.6 Formatting and Parsing 433
12.7 Interoperating with Legacy Code 436
Exercises 437
Chapter 13: Internationalization 441
13.1 Locales 442
13.2 Number Formats 447
13.3 Currencies 448
13.4 Date and Time Formatting 449
13.5 Collation and Normalization 451
13.6 Message Formatting 453
13.7 Resource Bundles 455
13.8 Character Encodings 458
13.9 Preferences 459
Exercises 461
Chapter 14: Compiling and Scripting 463
14.1 The Compiler API 463
14.2 The Scripting API 467
Exercises 472
Chapter 15: The Java Platform Module System 475
15.1 The Module Concept 476
15.2 Naming Modules 478
15.3 The Modular Hello, World! Program 478
15.4 Requiring Modules 480
15.5 Exporting Packages 482
15.6 Modules and Reflective Access 485
15.7 Modular JARs 488
15.8 Automatic Modules 489
15.9 The Unnamed Module 491
15.10 Command-Line Flags for Migration 491
15.11 Transitive and Static Requirements 493
15.12 Qualified Exporting and Opening 495
15.13 Service Loading 496
15.14 Tools for Working with Modules 497
Exercises 499
Index 501