`
`IN A NUTSHELL
`
`A Des/atop Quick Reference
`
`O’REILLY®
`
`Daw‘a’ Flanagan
`
`Page 1 of 238
`
`GOOGLE EXHIBIT 1031
`
`Page 1 of 238
`
`GOOGLE EXHIBIT 1031
`
`
`
`TIEIHSLHNVNI
`
`JAVA 2/1.2 & 1.3
`
`FLANAGAN
`
`O’REILLY"
`
`
`
`Page 2 of 238
`
`Page 2 of 238
`
`
`
`
`JAVA
`
`IN A NUTSHELL
`
`A Desktop Quick Reference
`
`Page 3 of 238
`
`Page 3 of 238
`
`
`
`THE
`JAVA”
`SERIES
`
`Exploring Java”
`
`Java“ Threads
`
`Java“ Network Programming
`
`Javam Virtual Machine
`
`Java” AWT Reference
`
`Java” Language Reference
`
`Java“ Fundamental Classes Reference
`
`Database Programming with
`JDBC'” and Javam
`
`Javaw Distributed Computing
`
`Developing Java Beans’"
`
`Java” Security
`
`Java“ Cryptography
`
`Java” Swing
`
`Java“ Servlet Programming
`
`Java” I/O
`
`Java'” 2D Graphics
`
`Enterprise JavaBeans’“
`
`Also from O’Reilly
`Java“ in a Nutshell
`
`Java” in a Nutshell, Deluxe Edition
`
`Java'" Examples in a Nutshell
`
`Java” Enterprise in a Nutshell
`
`Java” Foundation Classes in a Nutshell
`
`Java'" Power Reference: A Complete
`Searchable Resource on CD-ROM
`
`Page 4 of 238
`
`Page 4 of 238
`
`
`
`
`JAVA
`
`IN A NUTSHELL
`
`A Des/atop Quick Reference
`
`Third Edition
`
`David Flanagan
`
`Beijing ‘ Cambridge ' Fambam - Kb'ln - Paris - Sebastopol - Taipei . Tokyo
`
`O’REILLY®
`
`Page 5 of 238
`
`Page 5 of 238
`
`
`
`Javam in a Nutshell, Third Edition
`by David Flanagan
`
`Copyright © 1999, 1997, 1996 O’Reilly 8; Associates, Inc. All rights reserved.
`Printed in the United States of America
`
`Published by O’Reilly 8: Associates, Inc., 101 Morris Street, Sebastopol, CA 95472.
`
`Editor: Paula Ferguson
`
`Production Editor: Mary Anne Weeks Mayo
`
`Printing History:
`
`February 1996:
`
`First Edition.
`
`Second Edition.
`May 1997:
`November 1999: Third Edition.
`
`Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are
`registered trademarks and The JavaTM Series is a trademark of O’Reilly 8: Associates,
`Inc. The association of the image of aJavan tiger with the topic ofJava is a trademark
`of O’Reilly & Associates, Inc. Java and all Java—based trademarks and logos are
`trademarks or registered trademarks of Sun Microsystems, Inc, in the United States
`and other countries. O’Reilly 8; Associates, Inc. is independent of Sun Microsystems.
`
`Many of the designations used by manufacturers and sellers to distinguish their
`products are claimed as trademarks. Where those designations appear in this book,
`and O’Reilly 8: Associates, Inc. was aware of a trademark claim, the designations
`have been printed in caps or initial caps.
`
`While every precaution has been taken in the preparation of this book, the publisher
`assumes no responsibility for errors or omissions, or for damages resulting from the
`use of the information contained herein.
`
`ISBN: 1—56592—487-8
`[M]
`
`[2/00]
`
`Page 6 of 238
`
`Page 6 of 238
`
`
`
`Table of Contents
`
`Preface .................................................................................................. xi
`
`
`Part 1: Introducingjava
`
`Chapter 1 —Introdaction ................................................................. 3
`What Is Java? ........................................................................................... 3
`Key Benefits of Java ............................................................................... 6
`An Example Program ............................................................................. 9
`
`Chapter 2—java Syntaxfrom the Ground Up ......................... 19
`The Unicode Character Set ................................................................... 20
`Comments ............................................................................................. 20
`Identifiers and Reserved Words ........................................................... 21
`
`Primitive Data Types ............................................................................ 22
`Expressions and Operators .................................................................. 29
`Statements ............................................................................................. 43
`Methods ................................................................................................. 59
`
`Classes and Objects .............................................................................. 61
`Array Types ........................................................................................... 64
`Reference Types ................................................................................... 70
`Packages and the Java Namespace ...................................................... 76
`Java File Structure ................................................................................. 78
`Defining and Running Java Programs ................................................. 79
`Differences Between C and Java ......................................................... 80
`
`v
`
`Page 7 of 238
`
`Page 7 of 238
`
`
`
`Chapter 3—- Object—Oriented Programming injava ............... 82
`The Members of a Class ....................................................................... 82
`
`Creating and Initializing Objects .......................................................... 88
`Destroying and Finalizing Objects ....................................................... 92
`Subclasses and Inheritance .................................................................. 95
`Data Hiding and Encapsulation ......................................................... 104
`Abstract Classes and Methods ............................................................ 110
`Interfaces ............................................................................................. 112
`Inner Class Overview
`.................................................................... 117
`Static Member Classes ......................................................................... 118
`
`Member Classes .................................................................................. 119
`Local Classes ....................................................................................... 124
`
`Anonymous Classes ............................................................................ 127
`How Inner Classes Work .................................................................... 130
`Modifier Summary ............................................................................... 132
`C++ Features Not Found in Java ........................................................ 135
`
`Chapter 4— Tbejava Platform .................................................. 136
`
`Java Platform Overview ...................................................................... 136
`Strings and Characters ........................................................................ 138
`Numbers and Math ............................................................................. 140
`Dates and Times ................................................................................. 143
`Arrays ................................................................................................... 144
`Collections ........................................................................................... 145
`
`Types, Reflection, and Dynamic Loading .......................................... 147
`Threads ................................................................................................ 149
`Files and Directories ........................................................................... 155
`Input and Output Streams .................................................................. 154
`Networking .......................................................................................... 158
`Processes ............................................................................................. 161
`
`Security ................................................................................................ 161
`Cryptography ...................................................................................... 163
`
`Chapter 5—java Security ............................................................ 166
`
`Security Risks ...................................................................................... 166
`Java VM Security and Class File Verification ..................................... 167
`Authentication and Cryptography ...................................................... 168
`Access Control
`.................................................................................... 168
`
`Security for Everyone ......................................................................... 171
`Permission Classes .............................................................................. 175
`
`
`vi
`
`Page 8 of 238
`
`Page 8 of 238
`
`
`
`Chapter 6—favaBeans ................................................................. 1 78
`Bean Basics ......................................................................................... 179
`JavaBeans Conventions ...................................................................... 181
`Bean Contexts and Services ............................................................... 187
`
`Chapter 7—java Programming and Documentation '
`Conventions .............................................................................. 189
`
`Naming and Capitalization Conventions ........................................... 189
`Portability Conventions and Pure Java Rules .................................... 190
`Java Documentation Cements ......................................................... 192
`
`Chapter 8—fava Development Tools ........................................ 200
`
`appletviewer ........................................................................................ 200
`extcheck .............................................................................................. 204 ‘
`jar ......................................................................................................... 204
`jarsigner ............................................................................................... 206
`java ....................................................................................................... 208
`javac
`............... 214
`javadoc ................................................................................................ 217
`javah .................................................................................................... 221
`javakey ................................................................................................. 225
`javap .................................................................................................. 225
`jdb ........................................................................................................ 227
`keytool ................................................................................................. 231
`nativeZascii .......................................................................................... 234
`
`policytool ............................................................................................. 235
`serialver
`............. 256
`
`Part II: API Quick Reference
`
`How To Use This Quick Reference .............................................. 239
`
`Chapter 9# The java. beans Package ....................................... 248
`
`Chapter 1 0— The java. beans. heancontext Package ............. 264
`(
`
`Page 9 of 238
`
`vii
`
`Page 9 of 238
`
`
`
`Chapter 1 1— The java. z‘o Package ............................................ 280
`
`Chapter 12— The javalartg Package ....................................... 328
`
`Chapter 13— The javalangrefPackage ................................. 3 77
`
`Chapter 14— The javalangreflect Package ........................... 381
`
`Chapter 15— The java. math Package ...................................... 391
`
`Chapter 1 6— The java. net Package .......................................... 395
`
`Chapter 1 7— The javasecartty Package ................................. 418
`
`Chapter 18— The javasecarttyacl Package .......................... 453
`
`Chapter 19— The javasecart'tycert Package ........................ 45 7
`
`Chapter 20—— The java.secarz’ty.tnterfaces Package .............. 466
`
`Chapter 21 — The javasecarttyspec Package ........................ 4 70
`
`Chapter 22—— The javatext Package ......................................... 4 76
`
`Chapter 23— The javaattl Package ......................................... 49 7
`
`Chapter 24— The javaatt‘l.jar Package ................................... 544
`
`Chapter 25— Thejavaatt'lzzp Package .................................. 550
`
`Chapter 26—— Thejavax. crypto Package .................................. 561
`
`Chapter 2 7— The jar/ax. crypto. interfaces Package .............. 5 76
`
`
`viii
`
`Page 10 0f238
`
`Page 10 of 238
`
`
`
`Chapter 28— The javax. cm/ptospec Package ......................... 5 78
`
`Chapter 29—— Class, Method, and Field Index ........................ 584
`
`Index ................................................................................................. 615
`
`
`ix
`
`Page 11 0f238
`
`Page 11 of 238
`
`
`
`
`
`Preface
`
`This book is a desktop quick reference for JavaTM programmers, designed to sit
`faithfully by your keyboard while you program. Part I of the book is a fast~paced,
`“no-fluff” introduction to the Java programming language and the core APIs of the
`Java platform. Part II is a quick-reference section that succinctly details every class
`and interface of those core APIs. The book covers Versions 1.0, 1.1, 1.2, and 1.3
`beta of Java.
`
`Changes Since the Second Edition
`Readers who are familiar with the second edition of this book will notice a num-
`ber of changes in this edition. Most notably,
`the AWT and applet APIs are no
`longer documented in this book. The Java platform tripled in size between Java
`1.1 and Java 1.2. Accordingly, and unavoidably, jam in a Nutshell has been split
`into three volumes. The volume you are now reading documents only the essen-
`tial APIs of the platform, including the basic language and utility classes, as well as
`classes for input/output, networking, and security. See the Table of Contents for a
`complete list of the packages documented here.
`
`If you are a client—side programmer who is working with graphics or graphical
`user interfaces, you will probably want to supplement this book with jam Foun—
`dation Classes in a Nutshell, which documents all the graphics- and GUI—related
`classes, including the AWT, Swing, Java 2D, and applet APIs. And, if you are an
`server-side or enterprise programmer, you will likely be interested in Java Enter-
`prise in a Nutshell.
`
`Another big change is that Part I of this book has been almost entirely rewritten.
`The first and second editions of this book assumed knowledge of and experience
`with C or C++. Now that Java has come thoroughly into its own, that assumption
`no longer seems appropriate, so I have rewritten and expanded Chapters 2 and 3
`to explain Java without any reference to C, C++, or any other programming lan—
`guage. Programmers with a modest amount of experience should now be able to
`learn Java programming from this book. These introductory chapters are written in
`
`Page 12 0f238
`
`Page 12 of 238
`
`
`
`a tight, concise style, so programmers who already know Java should find them
`useful as a language reference.
`
`Another new feature of Part I is Chapter 4, The java Platform. This chapter is an
`introduction to the APIs documented in the reference section of the book.
`It
`
`includes more than 60 detailed API usage examples that show how to accomplish
`common tasks with the predefined classes of the Java platform.
`
`Finally, the quick—reference section in Part II of the book has a new look that dra—
`matically improves the readability of the reference material and packs even more
`API information into a small space. Even if you are already familiar with the sec-
`ond edition, you should take the time to read the How To Use This Quick Reference
`section at the beginning of Part II; it explains the new quick-reference format and
`shows you how to get the most out of it.
`
`Contents of This Boole
`
`The first eight chapters of this book document the Java language, the Java plat—
`form, and the Java development tools that are supplied with Sun’s Java SDK (soft—
`ware development kit):
`
`Chapter 1: Introduction
`This chapter is an overview of the Java language and the Java platform that
`explains the important features and benefits of Java.
`It concludes with an
`example Java program and walks the new Java programmer through it line by
`line.
`
`Chapter 2: java Syntax From the Ground Up
`This chapter explains the details of the Java programming language. It is a
`long and detailed chapter. Experienced Java programmers can use it as 3 lan-
`guage reference. Programmers with substantial experience with languages
`such as C and C++ should be able to pick up Java syntax by reading this
`chapter. The chapter does not assume years of programming experience, or
`even familiarity, with C or C++, however. Even beginning programmers, with
`only modest experience, should be able to learn Java programming by study-
`ing this chapter carefully.
`
`Chapter 3; Object-Oriented Programming infava
`This chapter describes how the basic Java syntax documented in Chapter 2 is
`used to write object-oriented programs in Java. The chapter assumes no prior
`experience with 00 programming. It can be used as a tutorial by new pro—
`grammers or as a reference by experienced Java programmers.
`
`Chapter 4: Thejava Platform
`This chapter is an overview of the essential Java APIs covered in this book, It
`contains numerous short examples that demonstrate how to perform common
`tasks with the classes and interfaces that comprise the Java platform. Program-
`mers who are new to Java, and especially those who learn best by example,
`should find this a valuable chapter.
`
`
`
`xii Preface
`
`Page 13 0f238
`
`Page 13 of 238
`
`
`
`Chapter 5: java Security
`This chapter explains the Java security architecture that allows untrusted code
`to run in a secure environment from which it cannot do any malicious dam—
`age to the host system. It is important for all Java programmers to have at
`least a passing familiarity with Java security mechanisms.
`
`Chapter 6.- javaBeans
`This chapter documents the JavaBeansTM component framework and explains
`what programmers need to know to create and use the reusable, embeddable
`Java classes known as beans.
`
`Chapter 7: java Programming and Documentation Conventions
`This chapter documents important and widely adopted Java programming
`conventions and also explains how you can make your Java code self—docu—
`menting by including specially formatted documentation cements.
`
`Chapter 8: java Development Tools
`The Java SDK shipped by Sun includes a number of useful Java development
`tools, most notably the Java interpreter and the Java compiler. This chapter
`documents those tools.
`
`These first eight chapters teach you the Java language and get you up and running
`with the Java APIs. The bulk of the book, however, is the API quick reference,
`Chapters 9 through 29, which is a succinct but detailed API reference formatted for
`optimum ease of use. Please be sure to read the How To Use This Quick Reference
`section, which appears at the beginning of the reference section; it explains how
`to get the most out of this section.
`
`Related Books
`O’Reilly & Associates, Inc. publishes an entire series of books on Java program-
`ming. These books include java Foundation Classes in a Nutshell and java Enter-
`prise in a Nutshell, which, as mentioned earlier, are companions to this book.
`
`A related reference work is the Java Power Reference. It is an electronic Java quick
`reference on CD-ROM that uses the java in a Nutshell style. But since it
`is
`designed for viewing in a web browser, it is fully hyperlinked and includes a pow-
`erful search engine. It is wider in scope but narrower in depth than the java in a
`Nutshell books. The java Power Reference covers all the APIs of the Java 2 plat-
`form, plus the APIs of many standard extensions. But it does not include tutorial
`chapters on the various APIs, nor does it include descriptions of the individual
`classes.
`
`You can find a complete list of Java books from O’Reilly & Associates at
`http://javaoreillycomfl Books that focus on the core Java APIs, as this one does,
`include:
`
`Exploringjava, by Pat Niemeyer and Joshua Peck
`A comprehensive tutorial introduction to Java, with an emphasis on client—side
`Java programming.
`
`
`
`Preface xiii
`
`Page 14 0f238
`
`Page 14 of 238
`
`
`
`java Threads, by Scott Oaks and Henry Wong
`Java makes multithreaded programming easy, but doing it right can still be
`tricky. This book explains everything you need to know.
`
`java 1/0, by Elliotte Rusty Harold
`Java’s stream-based input/output architecture is a thing of beauty. This book
`covers it in the detail it deserves.
`
`java Network Programming, by Elliotte Rusty Harold
`This book documents the Java networking APIS in detail.
`
`.
`java Security, by Scott Oaks
`This book explains the Java access-control mechanisms in detail and also doc-
`uments the authentication mechanisms of digital signatures and message
`digests.
`
`java Cryptography, by Jonathan Knudsen
`Thorough coverage of the Java Cryptography Extension, the javax.cnypto.*
`packages, and everything you need to know about cryptography in Java.
`
`Developingjava Beans, by Robert Englander
`A complete guide to writing components that work with the JavaBeans API.
`
`. Java Programming Resources Online
`
`This book is a quick reference designed for speedy access to frequently needed
`information. It does not, and cannot, tell you everything you need to know about
`Java. In addition to the books listed earlier, there are several valuable (and free)
`electronic sources of information about Java programming.
`
`Sun’s main web site for all things related to Java is bap://java.sun.com/ The web
`site specifically for Java developers is brazfldeueloperjavasuncom/ Much of the
`content on this developer site is password—protected, and access to it requires
`(free) registration.
`
`Sun distributes electronic documentation for all Java classes and methods in its
`javaa’oc HTML format. Although this documentation is somewhat difficult to navi-
`gate and is rough or outdated in places, it is still an excellent starting point when
`you need to know more about a particular Java package, class, method, or field. If
`you do not already have the javaa'oc files With your Java distribution, see
`bray/javasuncom/docs/ for a link to the latest available version. Sun also dis-
`tributes its excellent Java Tutorial online. You can browse and download it from
`bnp://jaua.sun.com/docs/booles/tutorial/
`
`For Usenet discussion (in English) about Java, try the complangjauaprogrammer
`and related comp.lang.java.* newsgroups. You can find the very comprehensive
`complangjavaprogrammer FAQ by Peter van der Linden at http://wwwafiacom/
`javafaq.btm.
`
`Finally, don’t forget O’Reilly’s Java web site. bta)://java.oreilly.com/ contains Java
`news and commentary and a monthly tips~and-tricks column by O’Reilly Java
`author Jonathan Knudsen.
`
`
`
`xiv Preface
`
`Page 15 0f238
`
`Page 15 of 238
`
`
`
`
`
`Examples Online
`The examples in this book are available online and can be downloaded from the
`home page for the book at http://wwworeilly,com/catalog/javanuB. You also may
`want to visit this site to see if any important notes or errata about the book have
`been published there.
`
`Conventions Used in This Boole
`
`We use the following formatting conventions in this book:
`
`Italic
`
`Used for emphasis and to signify the first use of a term. Italic is also used for
`commands, email addresses, web sites, FTP sites, file and directory names,
`and newsgroups.
`
`Bold
`
`Occasionally used to refer to particular keys on a computer keyboard or to
`portions of a user interface, such as the Back button or the Options menu.
`Letter Gothic
`
`Used in all Java code and generally for anything that you would type literally
`when programming,
`including keywords, data types, constants, method
`names, variables, class names, and interface names.
`
`Letter Gothic Oblique
`Used for the names of function arguments and generally as a placeholder to
`indicate an item that should be replaced with an actual value in your pro—
`gram.
`
`Franklin Gothic Book Condensed
`Used for the Java class synopses in the quick-reference section. This very nar-
`row font allows us to fit a lot of information on the page without a lot of dis-
`tracting line breaks. This font is also used for code entities in the descriptions
`in the quick-reference section.
`Franklin Gothic Deml Condensed
`
`Used for highlighting class, method, field, property, and constructor names in
`the quick-reference section, which makes it easier to scan the class synopses.
`
`Franklin Gothic Book Compressed Italic
`Used for method parameter names and comments in the quick—reference sec—
`tion.
`
`Requestfor Comments
`
`Please help us improve future editions of this book by reporting any errors, inac-
`curacies, bugs, misleading or confusing statements, and even plain old typos that
`you find. Please also let us know what we can do to make this book more useful
`to you. We take your comments seriously and will try to incorporate reasonable
`suggestions into future editions. You can contact us by writing:
`
`
`
`Preface xv
`
`Page 16 0f238
`
`Page 16 of 238
`
`
`
`O’Reilly & Associates, Inc.
`101 Morris Street
`Sebastopol, CA 95472
`1-800-998—9938 (in the United States or Canada)
`1-707-829-051 5 (international/local)
`1-707-829-0104 (fax)
`
`You can also send us messages electronically. To be put on the mailing list or
`request a catalog, send email to:
`
`info@oreilly.com
`
`To ask technical questions or comment on the book, send email to:
`
`b00kquestions®oreilb1.com
`
`We have a web site for the book, where we’ll list examples, errata, and any plans
`for future editions. You can access this page at:
`
`max/flown).oreilbzcom/camlog/jamnufi/
`
`For more information about this book and others, see the O’Reilly web site:
`
`bttp://www.oreilly.com
`
`How the Quick Reference Is Generated
`
`For the nerdy or merely inquisitive reader, this section explains a bit about how
`the quick-reference material in jam in a Nutshell and related books is created.
`
`As Java has evolved, so has my system for generating Java quick-reference mate-
`rial. The current system is part of a larger commercial documentation browser sys-
`tem I’m developing
`(Visit
`http://wwwdavidflanagun.com/jude/
`for more
`information about it). The program works in two passes: the first pass collects and
`organizes the API information, and the second pass outputs that information in the
`form of quick-reference chapters.
`
`The first pass begins by reading the class files for all of the classes and interfaces
`to be documented. Almost all of the API information in the quick reference is
`available in these class files. The notable exception is the names of method argu-
`ments, which are not stored in class files. These argument names are obtained by
`parsing the Java source file for each class and interface. Where source files are not
`available,
`I obtain method argument names by parsing the API documentation
`generated by javadoc. The parsers I use to extract API information from the source
`files and javadoc files are created using the Antlr parser generator developed by
`Terrence Parr of the Magelang Institute. (See btm://www.antlr.org/ for details on
`this very powerful programming tool.)
`
`Once the API information has been obtained by reading class files, source files,
`and javadoc files, the program spends some time sorting and cross—referencing
`everything. Then it stores all the API information into a single large data file.
`
`The second pass reads API information from that data file and outputs quick-refer-
`ence chapters using a custom SGML format. The SGML markup is fairly complex,
`but the code that generates it is quite mundane. Once I’ve generated the SGML
`
`xvi Preface
`
`Page 17 0f238
`
`Page 17 of 238
`
`
`
`output, I hand it off to the production team at O’Reilly & Associates. They process
`it and convert it to troff source code. The troff source is processed with the GNU
`grofi‘ program (fip://fip.gnu.org/gnu/grofl/) and a custom set of troff macros to
`produce PostScript output that is shipped directly to the printer.
`
`Acknowledgments
`
`Many people helped in the creation of this book, and I am grateful to them all. I
`am indebted to the many, many readers of the first two editions who wrote in
`with comments, suggestions, bug reports, and praise. Their many small contribu-
`tions are scattered throughout the book. Also, my apologies to those who made
`the many good suggestions that could not be incorporated into this edition.
`
`Paula Ferguson, a friend and colleague, has been the editor of all three editions of
`this book. Her careful reading and always-practical suggestions have made the
`book stronger, clearer, and more useful. She guided the evolution of Java in a
`Nutshell from a single book into a three—volume series and, at times, juggled edit~
`ing tasks for all three books at once. Finally, Paula went above and beyond the
`call of editorial duty by designing the hierarchy diagrams found at the start of each
`reference chapter.
`
`Mike Loukides provided high-level direction and guidance for the first edition of
`the book. Eric Raymond and Troy Downing reviewed that first edition—they
`helped spot my errors and omissions and offered good advice on making the
`book more useful to Java programmers.
`
`For the second edition, John Zukowski reviewed my Java 1.1 AWT quick—reference
`material, and George Reese reviewed most of the remaining new material. The
`second edition was also blessed with a “dream team" of technical reviewers from
`
`Sun. John Rose, the author of the Java inner class specification, reviewed the chap—
`ter on inner classes. Mark Reinhold, author of the new character stream classes in
`java . 1' 0, reviewed my documentation of these classes. Nakul Saraiya, the designer
`of
`the new Java Reflection API,
`reviewed my documentation
`of
`the
`java.lang.reflect package. I am very grateful to these engineers and architects;
`their efforts made this a stronger, more accurate book.
`
`The third edition also benefited greatly from the contributions of reviewers who
`are intimately familiar with the Java platform. Joshua Bloch, one of the primary
`authors of the Java collections framework, reviewed my descriptions of the collec-
`tions classes and interfaces. Joshua was also helpful in discussing the Timer and
`TimerTask classes of Java
`1.5 with me. Mark Reinhold,
`creator of
`the
`java .1 ang. r‘ef package, explained the package to me and reviewed my documen—
`tation of it. Scott Oaks reviewed my descriptions of the Java security and cryptog-
`raphy classes and interfaces. Joshua, Mark, and Scott are all engineers with Sun
`Microsystems, and I’m very grateful for their time. The documentation of the
`javax.crypto package and its subpackages was also reviewed by Jon Eaves. Jon
`worked on a clean-room implementation of the Java Cryptography Extension
`(which is available from 13134).-//www.abet.netuufl7 and his cements were quite
`helpful. Jon now works for Fluent Technologies (htmflwwwfluentcomaufl con-
`sulting in Java and electronic commerce. Finally, Chapter 1 was improved by the
`comments of reviewers who were not already familiar with the Java platform:
`
`Preface xvii
`
`Page 18 0f238
`
`Page 18 of 238
`
`
`
`Christina Byrne reviewed it from the standpoint of a novice programmer, and
`Judita Byrne of Virginia Power offered her comments as a professional COBOL
`programmer.
`
`The O’Reilly 8: Associates production team has done its usual fine work of creating
`a book out of the electronic files I submit. My thanks to them all. And a special
`thanks to Lenny Muellner and Chris Maden, who worked overtime to implement
`the new and improved format of the quick-reference section.
`
`As always, my thanks and love to Christie.
`
`David Flanagan
`http://wwwdam'dflanagan.com/
`September 1999
`
`xviii Preface
`
`Page 19 0f238
`
`Page 19 of 238
`
`
`
`PART I
`
`IntroducingJava
`
`Part I is an introduction to the Java language and the Java platformr These
`chapters provide enough information for you to get started using Java
`right away
`
`Chapter 1, Introduction
`Chapter 2, java Syntax From the Ground Up
`Chapter 3, Object-Oriented Programming infava
`Chapter 4, Tbefava Platform
`Chapter 5, java Security
`Chapter 6, javaBeans
`Chapter 7, java Programming and Documentation Conventions
`Chapter 8, java Development Tools
`
`Page 20 of 238
`
`Page 20 of 238
`
`
`
`O2
`
`E s
`
`.t
`2-.
`
`
`
`
`
`CHAPTER 1
`
`Introduction
`
`Welcome to Java. Since its introduction in late 1995, the Java language and plat-
`form have taken the programing world by storm. This chapter begins by explain-
`ing what Java is and why it has become so popular. Then, as a tutorial
`introduction to the language, it walks you through a simple Java program you can
`type in, compile, and run.
`
`What Isjava?
`
`it is important to distinguish between the Java programming
`In discussing Java,
`language, the Java V