Preface
Beautiful buildings are more than scientific. They are true organisms,spiritually conceived; works of art, using the best technology by inspirationrather than the idiosyncrasies of mere taste or any averaging by the committee mind.
--Frank Lloyd Wright
The Java™ programming language has been warmly received by the world community of software developers and Internet content providers. Users of the Internet and World Wide Web benefit from access to secure, platform-independent applications that can come from anywhere on the Internet. Software developers who create applications in the Java programming language benefit by developing code only once, with no need to "port" their applications to every software and hardware platform.
For many, the language was known first as a tool to create applets for the World Wide Web. An applet is a mini-application that runs inside a Web page. An applet can perform tasks and interact with users on their browser pages without using resources from the Web server after being downloaded. Some applets may, of course, talk with the server to do their job, but that's their business.
The Java programming language is indeed valuable for distributed network environments like the Web. However, it goes well beyond this domain to provide a powerful general-purpose programming language suitable for building a variety of applications that either do not depend on network features, or want them for different reasons. The ability to execute downloaded code on remote hosts in a secure manner is a critical requirement for many organizations.
Other groups use it as a general-purpose programming language for projects in which machine independence is less important. Ease of programming and safety features help you quickly produce working code. Some common programming errors never occur because of features like garbage collection and type-safe references. Support for multithreading caters to modern network-based and graphical user interface-based applications that must attend to multiple tasks simultaneously, and the mechanisms of exception handling ease the task of dealing with error conditions. While the built-in tools are powerful, it is a simple language in which programmers can quickly become proficient.
The Java programming language is designed for maximum portability with as few implementation dependencies as possible. An int, for example, is a 32-bit signed two's-complement integer in all implementations, irrespective of the CPU architecture on which the program executes. Defining everything possible about the language and its runtime environment enables users to run compiled code anywhere and share code with anyone who has a Java runtime environment.
About This Book
This book teaches the Java programming language to people who are familiar with basic programming concepts. It explains the language without being arduously formal or complete. This book is not an introduction to object-oriented programming, although some issues are covered to establish a common terminology. Other books in this series, and much online documentation, focus on applets, graphical interfaces, databases, components, and other specific kinds of programming tasks. For other references, see "Further Reading" at the end of the book.
This fourth edition provides integrated coverage of the Java programming language as provided by the Java™ 2 Platform Standard Edition 5.0, and specified by The Java™ Language Specification, Third Edition. It also covers most of the classes in the main packages (java.lang.*, java.util, java.io) as implemented in the J2SE™ Development Kit 5.0 (more commonly known as JDK 5.0, or in the older nomenclature JDK 1.5.0). If you have already read the third edition, you will find that there have been some major changes, both in the language and this book, since the 1.3 release that the third edition covered. There are new chapters on generics, enums and annotations--the major new language features introduced in the 5.0 release--and major new sections on assertions and regular expressions. There has been some restructuring of existing material to accommodate other changes and improve the general flow of the text--such as introducing the new boxing and unboxing conversions. But every single chapter has been updated in some way--whether it is a new language feature like variable argument methods, or the new enhanced for loop construct; or a new class such as Formatter for formatting text output; or changes to classes and methods caused by the addition of generics (such as the collections utilities and the reflection classes)--change permeates this entire fourth edition.
The Java programming language shares many features common to most programming languages in use today. The language should look familiar to C and C++ programmers because it was designed with C and C++ constructs where the languages are similar. That said, this book is neither a comparative analysis nor a "bridge" tutorial--no knowledge of C or C++ is assumed. C++ programmers, especially, may be as hindered by what they must unlearn as they are helped by their knowledge.