Ideal for working programmers new to Java, this best-selling book guides you through the language features and APIs of Java 21. Through fun, compelling, and realistic examples, author Marc Loy introduces you to Java fundamentals, including its class libraries, programming techniques, and idioms, with an eye toward building real applications. This updated sixth edition expands the content to cover lambdas and streams, and shows you how to use a functional paradigm in Java. You'll learn about the latest Java features introduced since the book's fifth edition, from JDK 15 through 21. You'll also take a deep dive into the virtual threads introduced as Project Loom in Java 19 and become familiar with the public release of JDK 21 LTS. The Java programming language was designed to be a machine-independent programming language that is both safe enough to traverse networks and powerful enough to replace native executable code. Java addresses the issues raised here and played a starring role in the growth of the internet, leading to where we are today. Initially, most of the enthusiasm for Java centered on its capabilities for building embedded applications for the web, called applets. But in the early days, applets and other client-side graphical user interfaces (GUIs) written in Java were limited. Today, Java has Swing, a sophisticated toolkit for building GUIs. This development has allowed Java to become a viable platform for developing traditional client-side application software, although many other contenders have entered this crowded field. This guide helps you: Learn the structure of the Java language and Java applications Write, compile, and execute Java applications Understand the basics of Java threading and concurrent programming Learn Java I/O basics, including local files and network resources Create compelling interfaces with an eye toward usability Learn how functional features have been integrated in Java Keep up with Java developments as new versions are released 1. A Modern Language Enter Java Java’s Origins Growing Up A Virtual Machine Java Compared with Other Languages Safety of Design Simplify, Simplify, Simplify... Type Safety and Method Binding Incremental Development Dynamic Memory Management Error Handling Threads Scalability Safety of Implementation The Verifier Class Loaders Security Managers Application and User-Level Security A Java Road Map The Past: Java 1.0–Java 20 The Present: Java 21 The Future Exercises 2. A First Application Java Tools and Environment Installing the JDK Installing Corretto on Linux Installing Corretto on macOS Installing Corretto on Windows Installing IntelliJ IDEA and Creating a Project Running the Project Grabbing the Learning Java Examples HelloJava Classes The main() Method Classes and Objects Variables and Class Types HelloComponent Inheritance The JComponent Class Relationships and Finger-Pointing Packages and Imports The paintComponent() Method HelloJava2: The Sequel Instance Variables Constructors Events The repaint() Method Interfaces Goodbye and Hello Again Review Questions Code Exercises 3. Tools of the Trade JDK Environment The Java VM Running Java Applications System Properties Preview Features The Classpath CLASSPATH on Unix and macOS CLASSPATH on Windows CLASSPATH Wildcards Modules The Java Compiler Compiling Preview Features Trying Java JAR Files The jar Utility Tool Wrap Up Review Questions Code Exercises Advanced Code Exercises A. Code Examples and IntelliJ IDEA Grabbing the Main Code Examples Installing IntelliJ IDEA Installing on Linux Installing on macOS Installing on Windows Importing the Examples Running the Examples B. Exercise Answers Chapter 1: A Modern Language Chapter 2: A First Application Code Exercises Chapter 3: Tools of the Trade Code Exercises Chapter 4: The Java Language Code Exercises Advanced Exercises Chapter 5: Objects in Java Code Exercises Advanced Exercises Chapter 6: Error Handling and Logging Code Exercises Advanced Exercises Chapter 7: Collections and Generics Code Exercises Advanced Exercises Chapter 8: Text and Core Utilities Code Exercises Chapter 9: Threads Code Exercises Chapter 10 Code Exercises Advanced Exercises Chapter 11 Code Exercises Advanced Exercises Chapter 12 Code Exercises Chapter 13 Code Exercises Chapter 14 Code Exercises If you're new to Java or new to programming, this best-selling book will guide you through the language features and APIs of Java 11. With fun, compelling, and realistic examples, authors Marc Loy, Patrick Niemeyer, and Daniel Leuck introduce you to Java fundamentals, including its class libraries, programming techniques, and idioms, with an eye toward building real applications. You'll learn powerful new ways to manage resources and exceptions in your applications, along with core language features included in recent Java versions. Develop with Java, using the compiler, interpreter, and other tools. Explore Java's built-in thread facilities and concurrency package. Learn text processing and the powerful regular expressions API. Write advanced networked or web-based applications and services If you're new to Java--or new to programming--the 5th edition of this bestselling book will guide you through the language features and APIs of Java 11 and beyond. With fun, compelling, and realistic examples, authors Marc Loy, Patrick Niemeyer, and Daniel Leuck introduce you to Java fundamentals--including its class libraries, programming techniques, and idioms--with an eye toward building real applications. Learn basic syntax, classes and objects, and other components Develop with Java, using the compiler, interpreter, and other tools Explore Java's built-in thread facilities and concurrency package Write networked or web-based applications and services Build graphical applications using Java component architecture Explore rich new desktop APIs