About This eBook....2
Preface....13
To the Reader....13
A Tour of This Book....17
Conventions....21
Sample Code....22
Acknowledgments....24
1. An Introduction to Java....27
1.1. Java as a Programming Platform....27
1.2. The Java “White Paper” Buzzwords....29
1.3. Java Applets and the Internet....41
1.4. A Short History of Java....44
1.5. Common Misconceptions about Java....53
2. The Java Programming Environment....59
2.1. Installing the Java Development Kit....59
2.2. Using the Command-Line Tools....68
2.3. Using an Integrated Development Environment....78
2.4. JShell....86
3. Fundamental Programming Structures in Java....91
3.1. A Simple Java Program....91
3.2. Comments....101
3.3. Data Types....102
3.4. Variables and Constants....119
3.5. Operators....128
3.6. Strings....153
3.7. Input and Output....188
3.8. Control Flow....208
3.9. Big Numbers....248
3.10. Arrays....255
4. Objects and Classes....287
4.1. Introduction to Object-Oriented Programming....287
4.2. Using Predefined Classes....299
4.3. Defining Your Own Classes....320
4.4. Static Fields and Methods....351
4.5. Method Parameters....367
4.6. Object Construction....381
4.7. Records....405
4.8. Packages....416
4.9. JAR Files....441
4.10. Documentation Comments....455
4.11. Class Design Hints....472
5. Inheritance....478
5.1. Classes, Superclasses, and Subclasses....478
5.2. Object: The Cosmic Superclass....527
5.3. Generic Array Lists....563
5.4. Object Wrappers and Autoboxing....580
5.5. Methods with a Variable Number of Arguments....590
5.6. Abstract Classes....593
5.7. Enumeration Classes....605
5.8. Sealed Classes....614
5.9. Pattern Matching....626
5.10. Reflection....642
5.11. Design Hints for Inheritance....699
6. Interfaces, Lambda Expressions, and Inner Classes....706
6.1. Interfaces....707
6.2. Lambda Expressions....763
6.3. Inner Classes....812
6.4. Service Loaders....848
6.5. Proxies....854
7. Exceptions, Assertions, and Logging....869
7.1. Dealing with Errors....870
7.2. Catching Exceptions....888
7.3. Tips for Using Exceptions....920
7.4. Using Assertions....928
7.5. Logging....940
7.6. Debugging Tips....972
8. Generic Programming....985
8.1. Why Generic Programming?....985
8.2. Defining a Simple Generic Class....991
8.3. Generic Methods....996
8.4. Bounds for Type Variables....999
8.5. Generic Code and the Virtual Machine....1004
8.6. Inheritance Rules for Generic Types....1017
8.7. Wildcard Types....1021
8.8. Restrictions and Limitations....1039
8.9. Reflection and Generics....1067
9. Collections....1089
9.1. The Java Collections Framework....1089
9.2. Interfaces in the Collections Framework....1111
9.3. Concrete Collections....1117
9.4. Maps....1165
9.5. Copies and Views....1195
9.6. Algorithms....1222
9.7. Legacy Collections....1249
10. Concurrency....1272
10.1. Running Threads....1273
10.2. Thread States....1283
10.3. Thread Properties....1289
10.4. Coordinating Tasks....1310
10.5. Synchronization....1348
10.6. Thread-Safe Collections....1413
10.7. Asynchronous Computations....1450
10.8. Processes....1486
11. Annotations....1504
11.1. Using Annotations....1505
11.2. Defining Annotations....1516
11.3. Annotations in the Java API....1523
11.4. Processing Annotations at Runtime....1534
11.5. Source-Level Annotation Processing....1542
11.6. Bytecode Engineering....1557
12. The Java Platform Module System....1575
12.1. The Module Concept....1576
12.2. Naming Modules....1579
12.3. The Modular “Hello, World!” Program....1581
12.4. Requiring Modules....1584
12.5. Exporting Packages....1588
12.6. Modular JARs....1597
12.7. Modules and Reflective Access....1601
12.8. Automatic Modules....1607
12.9. The Unnamed Module....1612
12.10. Command-Line Flags for Migration....1614
12.11. Transitive and Static Requirements....1617
12.12. Qualified Exporting and Opening....1621
12.13. Service Loading....1622
12.14. Tools for Working with Modules....1628
Appendix....1634
Whatever version of Java you are using, Core Java, Volume I: Fundamentals, Thirteenth Edition, will help you achieve a deep and practical understanding of the language and APIs. With hundreds of realistic examples, Java Champion Cay S. Horstmann demonstrates the most powerful and effective ways to get the job done.
Written for experienced programmers looking for in-depth coverage of the Java language and platform, this revised and updated edition continues to be the first choice for serious programmers. The carefully crafted sample programs demonstrate almost every language and library feature, as well as the newest capabilities introduced in Java 21. The examples are purposefully simple to focus on the major points, but, for the most part, they aren't fake and they don't cut corners. They should make good starting points for your own code.
This first of two volumes offers a detailed treatment of fundamental Java programming topics, including object-oriented programming, reflection and proxies, interfaces and inner classes, exception handling, generics, collections, lambda expressions, concurrency, annotations, and the Java Platform Module System.
See Core Java, Volume II: Advanced Features, Thirteenth Edition, for coverage of Java 21 enterprise features, including detailed discussions of networking, security, internationalization, and advanced UI programming.