This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com THE Java™ Programming Language, Fourth Edition By Ken Arnold, James Gosling, David Holmes Publisher: Addison Wesley Professional Pub Date: August 17, 2005 ISBN: 0-321-34980-6 Pages: 928 Table of Contents | Index Direct from the creators of the Java™ programming language, the completely revised fourth edition of The Java™ Programming Language is an indispensable resource for novice and advanced programmers alike Developers around the world have used previous editions to quickly gain a deep understanding of the Java programming language, its design goals, and how to use it most effectively in real-world development Now, Ken Arnold, James Gosling, and David Holmes have updated this classic to reflect the major enhancements in Java™ Standard Edition 5.0 (J2SE™ 5.0) The authors systematically cover most classes in Java's main packages, java.lang.*, java.util, and java.io, presenting in-depth explanations of why these classes work as they do, with informative examples Several new chapters and major sections have been added, and every chapter has been updated to reflect today's best practices for building robust, efficient, and maintainable Java software Key changes in this edition include New chapters on generics, enums, and annotations, the most powerful new language features introduced in J2SE 5.0 Changes to classes and methods throughout to reflect the addition of generics Major new sections on assertions and regular expressions Coverage of all the new language features, from autoboxing and variable argument methods to the enhanced for-loop and covariant return types Coverage of key new classes, such as Formatter and Scanner The Java™ Programming Language, Fourth Edition, is the definitive tutorial introduction to the Java language and essential libraries and an indispensable reference for all programmers, including those with extensive experience It brings together insights you can only get from the creators of Java: insights that will help you write software of exceptional quality This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com THE Java™ Programming Language, Fourth Edition By Ken Arnold, James Gosling, David Holmes Publisher: Addison Wesley Professional Pub Date: August 17, 2005 ISBN: 0-321-34980-6 Pages: 928 Table of Contents | Index Copyright The Java™ Series Preface About This Book Examples and Documentation Acknowledgments (Fourth Edition) Acknowledgments (Third Edition) Acknowledgments (Second Edition) Acknowledgments (First Edition) Chapter A Quick Tour Section 1.1 Getting Started Section 1.2 Variables Section 1.3 Comments in Code Section 1.4 Named Constants Section 1.5 Unicode Characters Section 1.6 Flow of Control Section 1.7 Classes and Objects Section 1.8 Methods and Parameters Section 1.9 Arrays Section 1.10 String Objects Section 1.11 Extending a Class Section 1.12 Interfaces Section 1.13 Generic Types Section 1.14 Exceptions Section 1.15 Annotations Section 1.16 Packages Section 1.17 The Java Platform Section 1.18 Other Topics Briefly Noted Chapter Classes and Objects Section 2.1 A Simple Class Section 2.2 Fields Section 2.3 Access Control Section 2.4 Creating Objects Section 2.5 Construction and Initialization Section 2.6 Methods Section 2.7 this Section 2.8 Overloading Methods Section 2.9 Importing Static Member Names Section 2.10 The main Method Section 2.11 Native Methods Chapter Extending Classes This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 3.1 An Extended Class Section 3.2 Constructors in Extended Classes Section 3.3 Inheriting and Redefining Members Section 3.4 Type Compatibility and Conversion Section 3.5 What protected Really Means Section 3.6 Marking Methods and Classes final Section 3.7 Abstract Classes and Methods Section 3.8 The Object Class Section 3.9 Cloning Objects Section 3.10 Extending Classes: How and When Section 3.11 Designing a Class to Be Extended Section 3.12 Single Inheritance versus Multiple Inheritance Chapter Interfaces Section 4.1 A Simple Interface Example Section 4.2 Interface Declarations Section 4.3 Extending Interfaces Section 4.4 Working with Interfaces Section 4.5 Marker Interfaces Section 4.6 When to Use Interfaces Chapter Nested Classes and Interfaces Section 5.1 Static Nested Types Section 5.2 Inner Classes Section 5.3 Local Inner Classes Section 5.4 Anonymous Inner Classes Section 5.5 Inheriting Nested Types Section 5.6 Nesting in Interfaces Section 5.7 Implementation of Nested Types Chapter Enumeration Types Section 6.1 A Simple Enum Example Section 6.2 Enum Declarations Section 6.3 Enum Constant Declarations Section 6.4 java.lang.Enum Section 6.5 To Enum or Not Chapter Tokens, Values, and Variables Section 7.1 Lexical Elements Section 7.2 Types and Literals Section 7.3 Variables Section 7.4 Array Variables Section 7.5 The Meanings of Names Chapter Primitives as Types Section 8.1 Common Fields and Methods Section 8.2 Void Section 8.3 Boolean Section 8.4 Number Section 8.5 Character Section 8.6 Boxing Conversions Chapter Operators and Expressions Section 9.1 Arithmetic Operations Section 9.2 General Operators Section 9.3 Expressions Section 9.4 Type Conversions Section 9.5 Operator Precedence and Associativity Section 9.6 Member Access This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 9.6 Member Access Chapter 10 Control Flow Section 10.1 Statements and Blocks Section 10.2 ifelse Section 10.3 switch Section 10.4 while and dowhile Section 10.5 for Section 10.6 Labels Section 10.7 break Section 10.8 continue Section 10.9 return Section 10.10 What, No goto? Chapter 11 Generic Types Section 11.1 Generic Type Declarations Section 11.2 Working with Generic Types Section 11.3 Generic Methods and Constructors Section 11.4 Wildcard Capture Section 11.5 Under the Hood: Erasure and Raw Types Section 11.6 Finding the Right Method Revisited Section 11.7 Class Extension and Generic Types Chapter 12 Exceptions and Assertions Section 12.1 Creating Exception Types Section 12.2 throw Section 12.3 The throws Clause Section 12.4 try, catch, and finally Section 12.5 Exception Chaining Section 12.6 Stack Traces Section 12.7 When to Use Exceptions Section 12.8 Assertions Section 12.9 When to Use Assertions Section 12.10 Turning Assertions On and Off Chapter 13 Strings and Regular Expressions Section 13.1 Character Sequences Section 13.2 The String Class Section 13.3 Regular Expression Matching Section 13.4 The StringBuilder Class Section 13.5 Working with UTF-16 Chapter 14 Threads Section 14.1 Creating Threads Section 14.2 Using Runnable Section 14.3 Synchronization Section 14.4 wait, notifyAll, and notify Section 14.5 Details of Waiting and Notification Section 14.6 Thread Scheduling Section 14.7 Deadlocks Section 14.8 Ending Thread Execution Section 14.9 Ending Application Execution Section 14.10 The Memory Model: Synchronization and volatile Section 14.11 Thread Management, Security, and ThreadGroup Section 14.12 Threads and Exceptions Section 14.13 ThreadLocal Variables Section 14.14 Debugging Threads Chapter 15 Annotations This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 15.1 A Simple Annotation Example Section 15.2 Annotation Types Section 15.3 Annotating Elements Section 15.4 Restricting Annotation Applicability Section 15.5 Retention Policies Section 15.6 Working with Annotations Chapter 16 Reflection Section 16.1 The Class Class Section 16.2 Annotation Queries Section 16.3 The Modifier Class Section 16.4 The Member classes Section 16.5 Access Checking and AccessibleObject Section 16.6 The Field Class Section 16.7 The Method Class Section 16.8 Creating New Objects and the Constructor Class Section 16.9 Generic Type Inspection Section 16.10 Arrays Section 16.11 Packages Section 16.12 The Proxy Class Section 16.13 Loading Classes Section 16.14 Controlling Assertions at Runtime Chapter 17 Garbage Collection and Memory Section 17.1 Garbage Collection Section 17.2 A Simple Model Section 17.3 Finalization Section 17.4 Interacting with the Garbage Collector Section 17.5 Reachability States and Reference Objects Chapter 18 Packages Section 18.1 Package Naming Section 18.2 Type Imports Section 18.3 Package Access Section 18.4 Package Contents Section 18.5 Package Annotations Section 18.6 Package Objects and Specifications Chapter 19 Documentation Comments Section 19.1 The Anatomy of a Doc Comment Section 19.2 Tags Section 19.3 Inheriting Method Documentation Comments Section 19.4 A Simple Example Section 19.5 External Conventions Section 19.6 Notes on Usage Chapter 20 The I/O Package Section 20.1 Streams Overview Section 20.2 Byte Streams Section 20.3 Character Streams Section 20.4 InputStreamReader and OutputStreamWriter Section 20.5 A Quick Tour of the Stream Classes Section 20.6 The Data Byte Streams Section 20.7 Working with Files Section 20.8 Object Serialization Section 20.9 The IOException Classes Section 20.10 A Taste of New I/O Chapter 21 Collections This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Chapter 21 Collections Section 21.1 Collections Section 21.2 Iteration Section 21.3 Ordering with Comparable and Comparator Section 21.4 The Collection Interface Section 21.5 Set and SortedSet Section 21.6 List Section 21.7 Queue Section 21.8 Map and SortedMap Section 21.9 enum Collections Section 21.10 Wrapped Collections and the Collections Class Section 21.11 Synchronized Wrappers and Concurrent Collections Section 21.12 The Arrays Utility Class Section 21.13 Writing Iterator Implementations Section 21.14 Writing Collection Implementations Section 21.15 The Legacy Collection Types Section 21.16 Properties Chapter 22 Miscellaneous Utilities Section 22.1 Formatter Section 22.2 BitSet Section 22.3 Observer/Observable Section 22.4 Random Section 22.5 Scanner Section 22.6 StringTokenizer Section 22.7 Timer and TimerTask Section 22.8 UUID Section 22.9 Math and StrictMath Chapter 23 System Programming Section 23.1 The System Class Section 23.2 Creating Processes Section 23.3 Shutdown Section 23.4 The Rest of Runtime Section 23.5 Security Chapter 24 Internationalization and Localization Section 24.1 Locale Section 24.2 Resource Bundles Section 24.3 Currency Section 24.4 Time, Dates, and Calendars Section 24.5 Formatting and Parsing Dates and Times Section 24.6 Internationalization and Localization for Text Chapter 25 Standard Packages Section 25.1 java.awt The Abstract Window Toolkit Section 25.2 java.applet Applets Section 25.3 java.beans Components Section 25.4 java.math Mathematics Section 25.5 java.net The Network Section 25.6 java.rmi Remote Method Invocation Section 25.7 java.security and Related Packages Security Tools Section 25.8 java.sql Relational Database Access Section 25.9 Utility Subpackages Section 25.10 javax.* Standard Extensions Section 25.11 javax.accessibility Accessibility for GUIs Section 25.12 javax.naming Directory and Naming Services This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 25.13 javax.sound Sound Manipulation Section 25.14 javax.swing Swing GUI Components Section 25.15 org.omg.CORBA CORBA APIs Appendix A Application Evolution Section A.1 Language, Library, and Virtual Machine Versions Section A.2 Dealing with Multiple Dialects Section A.3 Generics: Reification, Erasure, and Raw Types Appendix B Useful Tables Further Reading Java Platform Topics Object-Oriented Design Multithreaded Programming Generics Regular Expressions General Programming Techniques Related Languages Software Engineering Visual Design & GUI Design Colophon Note to Translators Article Exercises Quotes Index This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Copyright © 2006 Sun Microsystems, Inc 4150 Network Circle, Santa Clara, California 95054 U.S.A All rights reserved Use, duplication, or disclosure by the United States Government is subject to the restrictions set forth in DFARS 252.227-7013 (c)(1)(ii) and FAR 52.227-19 The release described in this book may be protected by one or more U.S patents, foreign patents, or pending applications Sun Microsystems, Inc (SUN) hereby grants to you a fully-paid, nonexclusive, nontransferable, perpetual, worldwide limited license (without the right to sublicense) under SUN's intellectual property rights that are essential to practice this specification This license allows and is limited to the creation and distribution of clean room implementations of this specification that: (i) include a complete implementation of the current version of this specification without subsetting or supersetting; (ii) implement all the interfaces and functionality of the standard java.* packages as defined by SUN, without subsetting or supersetting; (iii) not add any additional packages, classes or methods to the java.* packages; (iv) pass all test suites relating to the most recent published version of this specification that are available from SUN six (6) months prior to any beta release of the clean room implementation or upgrade thereto; (v) not derive from SUN source code or binary materials; and (vi) not include any SUN binary materials without an appropriate and separate license from SUN Sun, Sun Microsystems, Sun Microsystems Computer Corporation, the Sun logo, the Sun Microsystems Computer Corporation logo, Java, JavaSoft, JavaScript JDBC, JDBC Compliant, JavaOS, JavaBeans and HotJava are trademarks or registered trademarks of Sun Microsystems, Inc UNIX® is a registered trademark in the United States and other countries, exclusively licensed through X/Open Company, Ltd Apple and Dylan are trademarks of Apple Computer, Inc All other product names mentioned herein are the trademarks of their respective owners THIS PUBLICATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT THIS PUBLICATION COULD INCLUDE TECHNICAL INACCURACIES OR TYPOGRAPHICAL ERRORS CHANGES ARE PERIODICALLY ADDED TO THE INFORMATION HEREIN; THESE CHANGES WILL BE INCORPORATED IN NEW EDITIONS OF THE PUBLICATION SUN MICROSYSTEMS, INC MAY MAKE IMPROVEMENTS AND/OR CHANGES IN THE PRODUCT(S) AND/OR THE PROGRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME 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 the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals The authors and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests For more information, please contact: U S Corporate and Government Sales, (800) 3823419, corpsales@pearsontechgroup.com For sales outside the U S., please contact: International Sales, international@pearsoned.com Visit us on the Web: www.awprofessional.com Library of Congress Cataloging-in-Publication Data Arnold, Ken, 1958The Java programming language / Ken Arnold, James Gosling, David Holmes p cm Includes bibliographical references and index ISBN 0-321-34980-6 (pbk : alk paper) Java (Computer program language) I Gosling, James II Holmes, David (David Colin) III Title QA76.73.J38A76 2005 005.13'3 dc22 2005017029 All rights reserved Printed in the United States of America This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise For information regarding permissions, write to: Pearson Education, Inc., Rights and Contracts Department, One Lake Street, Upper Saddle River, NJ 07458 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com NJ 07458 Text printed in the United States on recycled paper at Courier in Stoughton, Massachusetts First printing, August 2005 Dedication This book is dedicated to the Java team From whose hard work and vision A mighty oak has grown To SusanK.A To Judy and KateJ.A.G To Lee, Taylor, and CaitlinD.H This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com The Java™ Series Ken Arnold, James Gosling, David Holmes The Java™ Programming Language, Third Edition Cynthia Bloch, Annette Wagner MIDP 2.0 Style Guide for the Java™ Platform, Micro Edition Joshua Bloch Effective Java™ Programming Language Guide Mary Campione, Kathy Walrath, Alison Huml The Java™ Tutorial, Third Edition: A Short Course on the Basics Mary Campione, Kathy Walrath, Alison Huml,Tutorial Team The Java™ Tutorial Continued: The Rest of the JDK™ Patrick Chan The Java™ Developers Almanac 1.4, Volume Patrick Chan The Java™ Developers Almanac 1.4, Volume Patrick Chan, Rosanna Lee The Java™ Class Libraries, Second Edition, Volume 2: java.applet, java.awt, java.beans Patrick Chan, Rosanna Lee, Doug Kramer The Java™ Class Libraries, Second Edition, Volume 1: java.io, java.lang, java.math, java.net, java.text, java.util Patrick Chan, Rosanna Lee, Doug Kramer The Java™ Class Libraries, Second Edition, Volume 1: Supplement for the Java™ Platform, Standard Edition, v1.2 Kirk Chen, Li Gong Programming Open Service Gateways with Java™ Embedded Server Zhiqun Chen Java Card™ Technology for Smart Cards: Architecture and Programmer's Guide Maydene Fisher, Jon Ellis, Jonathan Bruce JDBC™ API Tutorial and Reference, Third Edition Li Gong, Gary Ellison, Mary Dageforde Inside Java™ Platform Security, Second Edition: Architecture, API Design, and Implementation James Gosling, Bill Joy, Guy Steele, Gilad Bracha The Java™ Language Specification, Third Edition Doug Lea Concurrent Programming in Java™, Second Edition: Design Principles and Patterns Rosanna Lee, Scott Seligman JNDI API Tutorial and Reference: Building Directory-Enabled Java™ Applications Sheng Liang The Java™ Native Interface: Programmer's Guide and Specification Tim Lindholm, Frank Yellin The Java™ Virtual Machine Specification, Second Edition Roger Riggs, Antero Taivalsaari, Jim Van Peursem, Jyri Huopaniemi, Mark Patel, Aleksi Uotila This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Roger Riggs, Antero Taivalsaari, Jim Van Peursem, Jyri Huopaniemi, Mark Patel, Aleksi Uotila Programming Wireless Devices with the Java™ Platform, Micro Edition, Second Edition Sun Microsystems, Inc Java™ Look and Feel Design Guidelines: Advanced Topics Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour The JFC Swing Tutorial, Second Edition: A Guide to Constructing GUIs Seth White, Maydene Fisher, Rick Cattell, Graham Hamilton, Mark Hapner JDBC™ API Tutorial and Reference, Second Edition: Universal Data Access for the Java™ Platform Steve Wilson, Jeff Kesselman Java™ Platform Performance: Strategies and Tactics The Jini™ Technology Series Eric Freeman, Susanne Hupfer, Ken Arnold JavaSpaces™ Principles, Patterns, and Practice The Java™ Series, Enterprise Edition Stephanie Bodoff, Dale Green, Kim Haase, Eric Jendrock The J2EE™ Tutorial, Second Edition Rick Cattell, Jim Inscore, Enterprise Partners J2EE™ Technology in Practice: Building Business Applications with the Java™ Platform, Enterprise Edition Mark Hapner, Rich Burridge, Rahul Sharma, Joseph Fialli, Kim Haase Java™ Message Service API Tutorial and Reference: Messaging for the J2EE™ Platform Inderjeet Singh, Beth Stearns, Mark Johnson, Enterprise Team Designing Enterprise Applications with the Java™ Platform, Enterprise Edition Vlada Matena, Sanjeev Krishnan, Linda DeMichiel, Beth Stearns Applying Enterprise JavaBeans™, Second Edition: Component-Based Development for the J2EE™ Platform Bill Shannon, Mark Hapner, Vlada Matena, James Davidson, Eduardo Pelegri-Llopart, Larry Cable, Enterprise Team Java™ Platform, Enterprise Edition: Platform and Component Specifications Rahul Sharma, Beth Stearns, Tony Ng J2EE™ Connector Architecture and Enterprise Application Integration This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Preface Beautiful buildings are more than scientific They are true organisms, spiritually conceived; works of art, using the best technology by inspiration rather 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, platformindependent 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 miniapplication 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 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 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 interfacebased 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 This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] Queue This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] readAttrs RegionMatch reinterrupt remove replace Reuse Rose diagram RunPingPong This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] setArray setArrayInt setField shorterGetField shorterSetField showFinal ShowJoin ShowObject simpleCatch SimpleLookup SimpleSortDouble singleNewArray SortDouble SortDoubleMain sorted-collection sortedcollection-fixed SortMetrics sqrtInt 2nd sqrtIntFaster squeezeOut 2nd static_primes string-split StringAssign StringEquals StringObjectExample StringsDemo subclass [See Extending class(es)] Sum sumStream sunWithMoon sunWithMoonReplaceAll swapFirstWords swapWords synchronized_abs This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] TestSort threadgroup-in-constructor toUpperLower type search order TypeDesc This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com THE Java™ Programming Language, Fourth Edition By Ken Arnold, James Gosling, David Holmes Publisher: Addison Wesley Professional Pub Date: August 17, 2005 ISBN: 0-321-34980-6 Pages: 928 Table of Contents | Index Copyright The Java™ Series Preface About This Book Examples and Documentation Acknowledgments (Fourth Edition) Acknowledgments (Third Edition) Acknowledgments (Second Edition) Acknowledgments (First Edition) Chapter A Quick Tour Section 1.1 Getting Started Section 1.2 Variables Section 1.3 Comments in Code Section 1.4 Named Constants Section 1.5 Unicode Characters Section 1.6 Flow of Control Section 1.7 Classes and Objects Section 1.8 Methods and Parameters Section 1.9 Arrays Section 1.10 String Objects Section 1.11 Extending a Class Section 1.12 Interfaces Section 1.13 Generic Types Section 1.14 Exceptions Section 1.15 Annotations Section 1.16 Packages Section 1.17 The Java Platform Section 1.18 Other Topics Briefly Noted Chapter Classes and Objects Section 2.1 A Simple Class Section 2.2 Fields Section 2.3 Access Control Section 2.4 Creating Objects Section 2.5 Construction and Initialization Section 2.6 Methods Section 2.7 this Section 2.8 Overloading Methods Section 2.9 Importing Static Member Names Section 2.10 The main Method Section 2.11 Native Methods Chapter Extending Classes This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 3.1 An Extended Class Section 3.2 Constructors in Extended Classes Section 3.3 Inheriting and Redefining Members Section 3.4 Type Compatibility and Conversion Section 3.5 What protected Really Means Section 3.6 Marking Methods and Classes final Section 3.7 Abstract Classes and Methods Section 3.8 The Object Class Section 3.9 Cloning Objects Section 3.10 Extending Classes: How and When Section 3.11 Designing a Class to Be Extended Section 3.12 Single Inheritance versus Multiple Inheritance Chapter Interfaces Section 4.1 A Simple Interface Example Section 4.2 Interface Declarations Section 4.3 Extending Interfaces Section 4.4 Working with Interfaces Section 4.5 Marker Interfaces Section 4.6 When to Use Interfaces Chapter Nested Classes and Interfaces Section 5.1 Static Nested Types Section 5.2 Inner Classes Section 5.3 Local Inner Classes Section 5.4 Anonymous Inner Classes Section 5.5 Inheriting Nested Types Section 5.6 Nesting in Interfaces Section 5.7 Implementation of Nested Types Chapter Enumeration Types Section 6.1 A Simple Enum Example Section 6.2 Enum Declarations Section 6.3 Enum Constant Declarations Section 6.4 java.lang.Enum Section 6.5 To Enum or Not Chapter Tokens, Values, and Variables Section 7.1 Lexical Elements Section 7.2 Types and Literals Section 7.3 Variables Section 7.4 Array Variables Section 7.5 The Meanings of Names Chapter Primitives as Types Section 8.1 Common Fields and Methods Section 8.2 Void Section 8.3 Boolean Section 8.4 Number Section 8.5 Character Section 8.6 Boxing Conversions Chapter Operators and Expressions Section 9.1 Arithmetic Operations Section 9.2 General Operators Section 9.3 Expressions Section 9.4 Type Conversions Section 9.5 Operator Precedence and Associativity Section 9.6 Member Access This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 9.6 Member Access Chapter 10 Control Flow Section 10.1 Statements and Blocks Section 10.2 ifelse Section 10.3 switch Section 10.4 while and dowhile Section 10.5 for Section 10.6 Labels Section 10.7 break Section 10.8 continue Section 10.9 return Section 10.10 What, No goto? Chapter 11 Generic Types Section 11.1 Generic Type Declarations Section 11.2 Working with Generic Types Section 11.3 Generic Methods and Constructors Section 11.4 Wildcard Capture Section 11.5 Under the Hood: Erasure and Raw Types Section 11.6 Finding the Right Method Revisited Section 11.7 Class Extension and Generic Types Chapter 12 Exceptions and Assertions Section 12.1 Creating Exception Types Section 12.2 throw Section 12.3 The throws Clause Section 12.4 try, catch, and finally Section 12.5 Exception Chaining Section 12.6 Stack Traces Section 12.7 When to Use Exceptions Section 12.8 Assertions Section 12.9 When to Use Assertions Section 12.10 Turning Assertions On and Off Chapter 13 Strings and Regular Expressions Section 13.1 Character Sequences Section 13.2 The String Class Section 13.3 Regular Expression Matching Section 13.4 The StringBuilder Class Section 13.5 Working with UTF-16 Chapter 14 Threads Section 14.1 Creating Threads Section 14.2 Using Runnable Section 14.3 Synchronization Section 14.4 wait, notifyAll, and notify Section 14.5 Details of Waiting and Notification Section 14.6 Thread Scheduling Section 14.7 Deadlocks Section 14.8 Ending Thread Execution Section 14.9 Ending Application Execution Section 14.10 The Memory Model: Synchronization and volatile Section 14.11 Thread Management, Security, and ThreadGroup Section 14.12 Threads and Exceptions Section 14.13 ThreadLocal Variables Section 14.14 Debugging Threads Chapter 15 Annotations This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 15.1 A Simple Annotation Example Section 15.2 Annotation Types Section 15.3 Annotating Elements Section 15.4 Restricting Annotation Applicability Section 15.5 Retention Policies Section 15.6 Working with Annotations Chapter 16 Reflection Section 16.1 The Class Class Section 16.2 Annotation Queries Section 16.3 The Modifier Class Section 16.4 The Member classes Section 16.5 Access Checking and AccessibleObject Section 16.6 The Field Class Section 16.7 The Method Class Section 16.8 Creating New Objects and the Constructor Class Section 16.9 Generic Type Inspection Section 16.10 Arrays Section 16.11 Packages Section 16.12 The Proxy Class Section 16.13 Loading Classes Section 16.14 Controlling Assertions at Runtime Chapter 17 Garbage Collection and Memory Section 17.1 Garbage Collection Section 17.2 A Simple Model Section 17.3 Finalization Section 17.4 Interacting with the Garbage Collector Section 17.5 Reachability States and Reference Objects Chapter 18 Packages Section 18.1 Package Naming Section 18.2 Type Imports Section 18.3 Package Access Section 18.4 Package Contents Section 18.5 Package Annotations Section 18.6 Package Objects and Specifications Chapter 19 Documentation Comments Section 19.1 The Anatomy of a Doc Comment Section 19.2 Tags Section 19.3 Inheriting Method Documentation Comments Section 19.4 A Simple Example Section 19.5 External Conventions Section 19.6 Notes on Usage Chapter 20 The I/O Package Section 20.1 Streams Overview Section 20.2 Byte Streams Section 20.3 Character Streams Section 20.4 InputStreamReader and OutputStreamWriter Section 20.5 A Quick Tour of the Stream Classes Section 20.6 The Data Byte Streams Section 20.7 Working with Files Section 20.8 Object Serialization Section 20.9 The IOException Classes Section 20.10 A Taste of New I/O Chapter 21 Collections This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Chapter 21 Collections Section 21.1 Collections Section 21.2 Iteration Section 21.3 Ordering with Comparable and Comparator Section 21.4 The Collection Interface Section 21.5 Set and SortedSet Section 21.6 List Section 21.7 Queue Section 21.8 Map and SortedMap Section 21.9 enum Collections Section 21.10 Wrapped Collections and the Collections Class Section 21.11 Synchronized Wrappers and Concurrent Collections Section 21.12 The Arrays Utility Class Section 21.13 Writing Iterator Implementations Section 21.14 Writing Collection Implementations Section 21.15 The Legacy Collection Types Section 21.16 Properties Chapter 22 Miscellaneous Utilities Section 22.1 Formatter Section 22.2 BitSet Section 22.3 Observer/Observable Section 22.4 Random Section 22.5 Scanner Section 22.6 StringTokenizer Section 22.7 Timer and TimerTask Section 22.8 UUID Section 22.9 Math and StrictMath Chapter 23 System Programming Section 23.1 The System Class Section 23.2 Creating Processes Section 23.3 Shutdown Section 23.4 The Rest of Runtime Section 23.5 Security Chapter 24 Internationalization and Localization Section 24.1 Locale Section 24.2 Resource Bundles Section 24.3 Currency Section 24.4 Time, Dates, and Calendars Section 24.5 Formatting and Parsing Dates and Times Section 24.6 Internationalization and Localization for Text Chapter 25 Standard Packages Section 25.1 java.awt The Abstract Window Toolkit Section 25.2 java.applet Applets Section 25.3 java.beans Components Section 25.4 java.math Mathematics Section 25.5 java.net The Network Section 25.6 java.rmi Remote Method Invocation Section 25.7 java.security and Related Packages Security Tools Section 25.8 java.sql Relational Database Access Section 25.9 Utility Subpackages Section 25.10 javax.* Standard Extensions Section 25.11 javax.accessibility Accessibility for GUIs Section 25.12 javax.naming Directory and Naming Services This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Section 25.13 javax.sound Sound Manipulation Section 25.14 javax.swing Swing GUI Components Section 25.15 org.omg.CORBA CORBA APIs Appendix A Application Evolution Section A.1 Language, Library, and Virtual Machine Versions Section A.2 Dealing with Multiple Dialects Section A.3 Generics: Reification, Erasure, and Raw Types Appendix B Useful Tables Further Reading Java Platform Topics Object-Oriented Design Multithreaded Programming Generics Regular Expressions General Programming Techniques Related Languages Software Engineering Visual Design & GUI Design Colophon Note to Translators Article Exercises Quotes Index This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] Unicode Case Issues UnicodeBlockDemo unnamed-package Upper Unicode Text URL coverage use_distance useGetProxyClass UseLookup useSwapWords This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] Verbose volatile This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] walkThrough WhichChars wrong_tokens ... Volume 2: java. applet, java. awt, java. beans Patrick Chan, Rosanna Lee, Doug Kramer The Java Class Libraries, Second Edition, Volume 1: java. io, java. lang, java. math, java. net, java. text, java. util... Team The Java Tutorial Continued: The Rest of the JDK™ Patrick Chan The Java Developers Almanac 1.4, Volume Patrick Chan The Java Developers Almanac 1.4, Volume Patrick Chan, Rosanna Lee The Java ... "Further Reading" on page 755 This fourth edition provides integrated coverage of the Java programming language as provided by the Java Platform Standard Edition 5.0 and specified by the Java Language