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 in the past 15 years. Java is, arguably, the most popular programming language in the world, used by millions of developers on almost every kind of computer imaginable. In the past decade, 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 , Fourth 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 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 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, 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 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.
New Developments
This edition of Learning Java is actually the sixth 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, web services, and XML, which are now mature technologies.
We cover all of the important features of the latest release of Java, officially called Java Standard Edition (SE) 7, JDK 1.7. 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 and now we reach Java 7.
This release of Java reflects a mature language with relatively few syntactic changes but significant 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 6 and 7)
This edition of the book has been significantly reworked to be as complete and up-to-date as possible. It incorporates changes from both the Java 6 and Java 7 releases that occurred since the last edition of this book. New topics in this edition include:
New language features, including type inference in generics and improved exception handling and automatic resource management syntax
New concurrency utilities including the Fork-Join framework
The new NIO Files API, which allows new types of filesystem access to be implemented in Java
New versions of the Java Servlets (3.0) and web services APIs, including use of the new annotations-based deployment and built-in web service container
New version of JAXB (2.2) Java XML Binding, including use of the new annotations for binding Java to XML
Improved Swing desktop integration and enhancements to key Swing components such as JTable
Updated examples and analysis throughout the book
Using This Book
This book is organized roughly as follows:
Chapters provide a basic introduction to Java concepts and a tutorial to give you a jump start on Java programming.
discusses fundamental tools for developing with Java (the compiler, the interpreter, and the JAR file package).
Chapters describe the Java language itself, beginning with the basic syntax and then covering classes and objects, exceptions, arrays, enumerations, annotations, and much more.
covers generics and parameterized types in Java.
covers the languages built-in thread facilities and the Java Concurrency package, which should be of particular interest to advanced programmers.
covers text processing, formatting, scanning, string utilities, and the powerful regular expressions API.
covers much of the core API including utilities and collections.