This book is about the JavaTM language and programming 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 it hasnt slowed down much since. Java is now, arguably, the most popular programming language in the world, used by millions of developers on almost every kind of computer imaginable. In recent years Java has surpassed languages such as C++ and Visual Basic in terms of developer demand and become the de facto language for new developmentespecially for web-based applications and 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 , Third Edition attempts to live up to its name by mapping out the Java language, its class libraries, programming techniques, and idioms. Well dig deep into interesting areas and at least scratch the surface of the rest. 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 learn more on your own.
New Developments
This edition of Learning Java is actually the fifth 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 somewhat static role over the past couple of years in creating interactive web pages. In contrast, weve greatly expanded our coverage of server-side web applications and XML, which are now mature technologies.
We cover all of the important features of the latest release of Java, officially called Java 2 Standard Edition 5.0, JDK 1.5. Sun has changed the naming scheme many times over the years and this is the most confusing release ever! 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 this release Sun has skipped from Java Version 1.4 to the Java 5.0, but reprieved the term JDK and kept its numbering convention there. Weve had no choice but to accept the term Java 5.0 into our vocabulary. You cant fight marketing.
This release of Java is targeted at developers and has the biggest set of language changes since Javas birth. Weve tried to capture these new features and update every example in this book to reflect not only the current Java practice, but style.
New in This Edition
This edition of the book has been significantly reworked to be as complete and up to date as possible. New topics in this edition include:
New Java 5.0 language features, including typesafe enumerations, variable-length argument lists (varargs), the enhanced for loop, autoboxing, static imports, and annotations ()
A full chapter on generics and parameterized types ()
Full coverage of the new Java concurrency package, including details on executors, thread pools, read/write locks, and more ()
Printf-style text formatting and the new Scanner text-parsing API ()
New Collections classes, including Queue and Concurrent collections ()
Enhanced RMI ()
Using and writing web services with the Java Web Services Developer Pack ()
Coverage of NetBeans 4.x ()
Major XML enhancements, including XML schema and validation, JAXB XML binding, XPath Expressions, and XInclude document processing ()
Introduction to the Eclipse IDE 3.x () and Audience
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, GUIs, and XML. 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 good, 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 XML processing, so you should be familiar with the basic ideas behind web browsers, servers, and documents.