This book is about the Java programming language and environment. Whether you are a software developer or just someone who uses the Internet in your daily life, youve undoubtedly heard about Java. Its introduction was one of the most exciting developments in the history of the Web and Java applications have powered much of the growth of business on the Internet. Java is, arguably, the most popular programming language in the world, used by millions of developers on almost every kind of computer imaginable. Java has surpassed languages such as C++ and Visual Basic in terms of developer demand and has become the de facto language for certain kinds of developmentespecially for web-based services. Most universities are now using Java in their introductory courses alongside the other important modern languages. Perhaps you are using this text in one of your classes right now!
This book gives you a thorough grounding in Java fundamentals and APIs. Learning Java, Fifth Edition, attempts to live up to its name by mapping out the Java language and its class libraries, programming techniques, and idioms. Well dig deep into interesting areas and at least scratch the surface of other popular topics. Other titles from OReilly pick up where we leave off and provide more comprehensive information on specific areas and applications of Java.
Whenever possible, we provide compelling, realistic, and fun examples and avoid merely cataloging features. The examples are simple, but hint at what can be done. We wont be developing the next great killer app in these pages, but we hope to give you a starting point for many hours of experimentation and inspired tinkering that will lead you to develop one yourself.
Who Should Read This Book
This book is for computer professionals, students, technical people, and Finnish hackers. Its for everyone who has a need for hands-on experience with the Java language with an eye toward building real applications. This book could also be considered a crash course in object-oriented programming, networking, and user interfaces. As you learn about Java, youll also learn a powerful and practical approach to software development, beginning with a deep understanding of the fundamentals of Java and its APIs.
Superficially, Java looks like C or C++, so youll have a tiny head start in using this book if you have some experience with one of these languages. If you do not, dont worry. Dont make too much of the syntactic similarities between Java and C or C++. In many respects, Java acts like more dynamic languages such as Smalltalk and Lisp. Knowledge of another object-oriented programming language should certainly help, although you may have to change some ideas and unlearn a few habits. Java is considerably simpler than languages such as C++ and Smalltalk. If you learn well from concise examples and personal experimentation, we think youll like this book.
The last part of this book branches out to discuss Java in the context of web applications, web services, and request processing, so you should be familiar with the basic ideas behind web browsers, servers, and documents.
New Developments
This edition of Learning Java is actually the seventh editionupdated and retitledof our original, popular Exploring Java. With each edition, weve taken great care not only to add new material covering additional features, but to thoroughly revise and update the existing content to synthesize the coverage and add years of real-world perspective and experience to these pages.
One noticeable change in recent editions is that weve deemphasized the use of applets, reflecting their diminished role in recent years in creating interactive web pages. In contrast, weve greatly expanded our coverage of Java web applications and web services which are now mature technologies.
We cover all of the important features of the latest long-term support release of Java, officially called Java Standard Edition (SE) 11, OpenJDK 11, but we also add in a few details from the feature releases of Java 12, Java 13, and Java 14. Sun (Javas keeper before Oracle) has changed the naming scheme many times over the years. Sun coined the term Java 2 to cover the major new features introduced in Java version 1.2 and dropped the term JDK in favor of SDK. With the sixth release, Sun skipped from Java version 1.4 to Java 5.0, but reprieved the term JDK and kept its numbering convention there. After that, we had Java 6, Java 7, and so on and now we reach Java 14.
This release of Java reflects a mature language with occasional syntactic changes and updates to APIs and libraries. Weve tried to capture these new features and update every example in this book to reflect not only the current Java practice, but style as well.
New in This Edition (Java 11, 12, 13, 14)
This edition of the book continues our tradition of rework to be as complete and up-to-date as possible. It incorporates changes from both the Java 11again, the long term support versionand Java 12, 13, and 14 feature releases. (More on the specifics of the Java features included and excluded in recent releases in .) New topics in this edition include:
New language features, including type inference in generics and improved exception handling and automatic resource management syntax
New interactive playground, jshell
, for trying out code snippets
The proposed