Register your product to gain access to bonus material or receive a coupon.
This book provides an insider's view of the Java technology by posing and answering the most important, frequently asked questions about the Java programming language, Java applets, and Java stand-alone applications. The Java FAQ is unique in that it draws from the tens of thousands of questions sent to java@java.sun.com and provides authoritative answers direct from the creators of the Java programming language at JavaSoft.
Presented in a handy question-and-answer format, The Java FAQ contains over 200 of the most important and informative of these questions together with concise explanations and creative solutions. The book is a powerful reference that can quickly help you over common stumbling blocks. Representing the collective wisdom of the JavaSoft team, it is an excellent resource for design tips, practical examples, style guidelines, insightful explanations, and insider information that will save you time and improve the quality of your Java programming.
The questions encompass the gamut of Java topics: objects, classes, methods, interfaces, exceptions, arrays, the virtual machine, applets, AWT components and containers, layouts, events, images, threads, sockets, and more. Well indexed and thoroughly cross-referenced, the book enables you to quickly locate precisely the information you need.
Appropriate for Java programmers of all levels, The Java FAQ includes clearly worded explanations to fundamental questions, such as:
Experienced Java programmers will benefit from pointed answers to more sophisticated questions, including:
0201634562B04062001
Preface.
1. Classes, Interfaces, and Packages.
Objects, Classes, and Methods.
Subclassing, Overloading, and Overriding.
Interfaces and Abstract Classes.
Packages and Access Modifiers.
Constants and Expressions.
Variables and Methods.
Arrays.
Exceptions.
Applets versus Applications.
Installing Applets.
Applet User Interface.
Applet Program Structure.
Applet Communication.
Miscellaneous.
Components, Containers, and Peers.
Windows, Frames, and Dialogs.
Miscellaneous.
Event Classes, Listeners, and Methods.
Semantic Events.
Low-level Events.
Drawing AWT Components.
Loading and Drawing Images.
Images-JDK 1.0.2.
Images-JDK 1.1.
Creating and Controlling Threads.
Thread Interactions.
User Threads versus System Threads.
Basic Input and Output.
URL Connections.
Internet Addresses.
Sockets.
Classes in java.lang and java.util.
Audio.
Miscellaneous.
Java technology has achieved remarkably widespread use in a very short time. The broad acceptance of Java reflects Java's technical strengths and feature set: platform-neutrality, dynamism, object-orientation, garbage collection, security, concurrency, robustness, and Internet savvy. The Java language has established itself as a mature, general-purpose programming language, and the standard Java class libraries provide an ever-broadening platform supporting a wide spectrum of application development.
Nevertheless, the speed and passion with which many developers have adopted Java shows that more than just technical soundness is at work. Java is fun to use and practical. It removes tedious and error-prone parts of application development such as memory management and cross-platform porting. It allows the developer to focus more energy on program design and functionality. The language is also comparatively easy to learn, thanks to a strong principle that guided the creation of Java: "Keep it simple!" An important corollary to this principle is: "Keep it learnable!" Java is not only fun to use but also fun to learn.
This book is a tool for developers learning to use Java. Its primary goals are unabashedly pragmatic:
The Java FAQ is not a fully detailed treatise on Java technology-for this, see The Java Language Specification, The Java Virtual Machine Specification, or one of the API reference books in the Java Series. Nor is it a carefully guided, sequenced exposition of Java-for this, see The Java Programming Language or The Java Tutorial.
This book, by means of its frequently asked-question (FAQ) format, takes direct advantage of a teacher's two favorite tools, questions and examples. Questions specify an informational need: if you can spell out what information you are missing, you are more than halfway towards attaining it. A question sets the context for linking new information into existing knowledge; it establishes the relevance (or usefulness) of the information.
Examples, likewise, give a penetrating edge to information. A specific example is usually easier to grasp than the general idea it illustrates. Sample code, moreover, is an especially useful form of example, since it can often be built into larger, working programs.
What qualifies as a frequently asked question? The primary source of questions for this book was the e-mail traffic at the java@java.sun.com address. This e-mail address was the default technical support pipeline for Java technology, especially in the formative period when Java and HotJava were progressing from a 1.0 alpha release, to beta, and finally to FCS (First Customer Ship). Although the term frequently asked questions suggests a collection of the most common questions (plus answers), this book has a slightly different target: frequently ask-worthy questions, that is, the questions you need to have answered in order to learn Java quickly and use it effectively. The Java FAQ aims for the question behind the question: the more general information gap or misunderstanding that, when filled or corrected, can answer a host of more specific questions. When you ask a question, it is important to know if your question has been answered. Thus, this book follows the admirable example set by The C++ FAQs (by Cline and Lomow, Addison-Wesley, 1995) of providing a highlighted short answer immediately following each question. This gives the answer in a nutshell, and the rest of the answer then explains and exemplifies the nutshell answer.
Many answers end in a pointer in the form of a partial URL (Uniform Resource Locator), such as GrabPixelsExample.html. These pointers refer to web pages containing sample code, applets, or other example material related to the answer. You can access these web pages by following links starting from the Java Series home page at the JavaSoft web site: http://java.sun.com/Series.
Each question-answer pair is intended to stand on its own as far as possible, but numerous cross references are included to indicate connections or dependencies in the material. You can dive into the middle of the book and follow leads from there, or you can start at the beginning and read straight through.
The Java FAQ covers the Java language, the Java Virtual Machine, and the standard classes in the following packages: java.lang, java.applet, java.awt, java.awt.image, java.awt.event, java.io, java.net, and java.util. This is essentially the contents of Sun's Java Devloper's Kit (JDK) 1.0 release together with updated information for the JDK 1.1 release. Information and sample code specific to one or another release is flagged explicitly throughout the book: "JDK 1.0.2" for the version most widely deployed during the span of this book's writing and "JDK 1.1" for the family of releases from JavaSoft in the first half of 1997 (JDK 1.1, 1.1.1, and 1.1.2). Packages representing wholly new functionality added in the JDK 1.1, such as java.rmi, java.beans, and java.security, are not covered.
This book would not have been possible but for the professional and personal assistance of many fine people at JavaSoft and elsewhere. Lisa Friendly first conceived of the book and encouraged me to take it on. Her patient yet persistent care as series editor helped me stick out this large project to the end. Carla Schroer graciously allowed me to take on the commitment despite other duties that were already claiming more than 100 percent of my time. Mary Aline's detailed edits of several early draft chapters reminded me to keep the writing clear, simple, and pleasantly grammatical. Mary Campione, Eric Chu, Jazmin Ellis, Doug Kramer, Nancy Lee, Rick Levenson, Marvin Ma, Ron Mandel, Freeman Murray, Scott Rautmann, Richard Scorer, Greg Voss, and Kathy Walrath added that nice human touch to my work environment, improving the quality of both my work time and my break time. For technical assistance with wide-ranging material, I am indebted to Tom Ball, Dave Brown, Patrick Chan, Dave Connelly, Jeff Dinkins, Pavani Diwanji, Amy Fowler, Jim Graham, Jeannette Hung, Herb Jellinek, Tim Lindholm, Marianne Mueller, Tim Prinzing, John Rose, Georges Saab, Nakul Saraiya, Sami Shaio, Arthur van Hoff, Chris Warth, and Frank Yellin. It was a delight to work with and learn from such a talented group of engineers. At Addison Wesley, Mike Hendrickson, Katie Duffy, Marina Lang, and Simone Payment made the difficult process of book development as sane as possible. Their good humor, hard work, and courteous professionalism go beyond the call of duty. Addison Wesley's manuscript reviewers and proofreaders considerably improved the book by their detailed comments and constructive criticism. In the later stages of the game, Vicki Hochstedler helped me navigate the joys and agonies of putting the book into final format, and Rosemary Simpson pulled together a painstaking and powerful index.
Above all, I am indebted to my family, who understand the demands of a normal job but gave up far more because of this book. My wife, Jean, is a gem. Her intelligence, honesty, thoughtfulness, and dead-on knack for the essential have been a cornerstone of my life and work for fifteen years. Thanks to her, I hope this book has not just content, but spirit. Our children, Kirsti, Silva, and Justin, are potent lessons in the value, challenge, and joy of life. Getting more time again to grow and play with them was special motivation for me to bring this project to conclusion. The household had one frequently asked question that couldn't be answered until the very end: "When will the book be done?" Well, the answer to that is finally, happily, at hand.
Jonni Kanerva
Mountain View, California
June, 1997