The Java API documentation can be downloaded to your local hard disk or viewed on line. To download the Java API documentation, go to java.sun.com/j2se/5.0/download.jsp and locate the DOWNLOAD link in the J2SE v 1.5.0 Documentation section. You will be asked to accept a license agreement. To do this, click Accept, then click Continue. Click the Java(TM) 2 SDK, Standard Edition Documentation 1.5.0, English link to begin the download. After downloading the file, you can use a ZIP file-extraction program, such as WinZip (www.winzip.com), to extract the files. If you are using Windows, extract the contents to your jdk1.5.0 directory or the directory where you installed Java. (See the Before You Begin section of this book for information on installing Java.) To view the API documentation on your local hard disk in Microsoft Windows, open C:Program FilesJavajdk1.5.0docsapiindex.html page in your browser. To view the API documentation on line, go to java.sun.com/j2se/1.5.0/docs/api/index.html (Fig. G.1).
Figure G.1. Java API overview. (Courtesy of Sun Microsystems, Inc.)
Frames in the API Documentation's index.html Page
The API documentation is divided into three frames (see Fig. G.1). The upper-left frame lists all of the Java API's packages in alphabetical order. The lower-left frame initially lists the Java API's classes and interfaces in alphabetical order. Interface names are displayed in italic. When you click a specific package in the upper-left frame, the lower-left frame lists the classes and interfaces of the selected package. The right frame initially provides a brief description of each package of the Java API specificationread this overview to become familiar wth the general capabilities of the Java APIs. If you select a class or interface in the lower-left frame, the right frame displays information about that class or interface.
Important Links in the index.html Page
At the top of the right frame (Fig. G.1), there are four linksTree, Deprecated, Index and Help. The Tree link displays the hierarchy of all packages, classes and interfaces in a tree structure. The Deprecated link displays interfaces, classes, exceptions, fields, constructors and methods that should no longer be used. The Index link displays classes, interfaces, fields, constructors and methods in alphabetical order. The Help link describes how the API documentation is organized. You should probably begin by reading the Help page.
Viewing the Index Page
If you do not know the name of the class you are looking for, but you do know the name of a method or field, you can use the documentation's index to locate the class. The Index link is located near the upper-right corner of the right frame. The index page (Fig. G.2) displays fields, constructors, methods, interfaces and classes in alphabetical order. For example, if you are looking for Scanner method hasNextInt, but do not know the class name, you can click the H link to go to the alphabetical listing of all items in the Java API that begin with "h". Scroll to method hasNextInt (Fig. G.3). Once there, each method named hasNextInt is listed with the package name and class to which the method belongs. From there, you can click the class name to view the class's complete details, or you can click the method name to view the method's details.
Figure G.2. Viewing the Index page. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1429 in the print version)
Figure G.3. Scroll to method hasNextInt. (Courtesy of Sun Microsystems, Inc.)
Viewing a Specific Package
When you click the package name in the upper-left frame, all classes and interfaces from that package are displayed in the lower-left frame and are divided into five subsectionsInterfaces, Classes, Enums, Exceptions and Errorseach listed alphabetically. For example, when you click javax.swing in the upper-left frame, the contents of package javax.swing are displayed in the lower-left frame (Fig. G.4). You can click the package name in the lower-left frame to get an overview of the package. If you think that a package contains several classes that could be useful in your application, the package overview can be especially helpful.
Figure G.4. Clicking a package name in the upper-left frame to view all classes and interfaces declared in this package. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1431 in the print version)
Viewing the Details of a Class
When you click a class name or interface name in the lower-left frame, the right frame displays the details of that class or interface. First you will see the class's package name followed by a hierarchy that shows the class's relationship to other classes. You will also see a list of the interfaces implemented by the class and the class's known subclasses. Figure G.5 shows the beginning of the documentation page for class JButton from the javax.swing package. The page first shows the package name in which the class appears. This is followed by the class hierarchy that leads to class JButton, the interfaces class JButton implements and the subclasses of class JButton. The bottom of the right frame shows the beginning of class JButton's description. Note that when you look at the documentation for an interface, the right frame does not display a hierarchy for that interface. Instead, the right frame lists the interface's superinterfaces, known subinterfaces and known implementing classes.
Figure G.5. Clicking a class name to view detailed information about the class. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1432 in the print version)
Summary Sections in a Class's Documentation Page
Other parts of each API page are listed below. Each part is presented only if the class contains or inherits the items specified. Class members shown in the summary sections are public unless they are explicitly marked as protected. A class's private members are not shown in the documentation, because they cannot be used directly in your programs.
Figure G.6. Field Summary section of class Color. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1433 in the print version)
Figure G.7. Constructor Summary section of class JButton. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1433 in the print version)
Figure G.8. Method Summary section of class BufferedInputStream. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1434 in the print version)
Note that the summary sections typically provide only a one-sentence description of a class member. Additional details are presented in the detail sections discussed next.
Detail Sections in a Class's Documentation Page
After the summary sections are detail sections that normally provide more discussion of particular class members. There is not a detail section for nested classes. When you click the link in the Nested Class Summary for a particular nested class, a documentation page describing that nested class is displayed. The detail sections are described below.
Figure G.9. Field Detail section of class Color. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1435 in the print version)
Figure G.10. Constructor Detail section of class JButton. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1435 in the print version)
Figure G.11. Method Detail section of class BufferedInputStream. (Courtesy of Sun Microsystems, Inc.)
(This item is displayed on page 1436 in the print version)
As you look through the documentation, you will notice that there are often links to other fields, methods, nested-classes and top-level classes. These links enable you to jump from the class you are looking at to another relevant portion of the documentation.
Introduction to Computers, the Internet and the World Wide Web
Introduction to Java Applications
Introduction to Classes and Objects
Control Statements: Part I
Control Statements: Part 2
Methods: A Deeper Look
Arrays
Classes and Objects: A Deeper Look
Object-Oriented Programming: Inheritance
Object-Oriented Programming: Polymorphism
GUI Components: Part 1
Graphics and Java 2D™
Exception Handling
Files and Streams
Recursion
Searching and Sorting
Data Structures
Generics
Collections
Introduction to Java Applets
Multimedia: Applets and Applications
GUI Components: Part 2
Multithreading
Networking
Accessing Databases with JDBC
Servlets
JavaServer Pages (JSP)
Formatted Output
Strings, Characters and Regular Expressions
Appendix A. Operator Precedence Chart
Appendix B. ASCII Character Set
Appendix C. Keywords and Reserved Words
Appendix D. Primitive Types
Appendix E. (On CD) Number Systems
Appendix F. (On CD) Unicode®
Appendix G. Using the Java API Documentation
Appendix H. (On CD) Creating Documentation with javadoc
Appendix I. (On CD) Bit Manipulation
Appendix J. (On CD) ATM Case Study Code
Appendix K. (On CD) Labeled break and continue Statements
Appendix L. (On CD) UML 2: Additional Diagram Types
Appendix M. (On CD) Design Patterns
Appendix N. Using the Debugger
Inside Back Cover