Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 684 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
684
Dung lượng
7,75 MB
Nội dung
The Java ™ Language Specification Third Edition The Java ™ Series The Java ™ Programming Language Ken Arnold, James Gosling and David Holmes ISBN 0-201-70433-1 The Java ™ Language Specification Third Edition James Gosling, Bill Joy, Guy Steele and Gilad Bracha ISBN 0-321-24678-0 The Java ™ Virtual Machine Specification Second Edition Tim Lindholm and Frank Yellin ISBN 0-201-43294-3 The Java ™ Application Programming Interface, Volume 1: Core Packages James Gosling, Frank Yellin, and the Java Team ISBN 0-201-63452-X The Java ™ Application Programming Interface, Volume 2: Window Toolkit and Applets James Gosling, Frank Yellin, and the Java Team ISBN 0-201-63459-7 The Java ™ Tutorial: Object-Oriented Programming for the Internet Mary Campione and Kathy Walrath ISBN 0-201-63454-6 The Java ™ Class Libraries: An Annotated Reference Patrick Chan and Rosanna Lee ISBN 0-201-63458-9 The Java ™ FAQ: Frequently Asked Questions Jonni Kanerva ISBN 0-201-63456-2 The Java ™ Language Specification Third Edition James Gosling Bill Joy Guy Steele Gilad Bracha ADDISON-WESLEY Boston ● San Francisco ● New York ● Toronto ● Montreal London ● Munich ● Paris ● Madrid Capetown ● Sydney ● Tokyo ● Singapore ● Mexico City The Java Language Specification iv Copyright 1996-2005 Sun Microsystems, Inc. 4150 Network Circle, Santa Clara, California 95054 U.S.A. All rights reserved. Duke logo™ designed by Joe Palrang. RESTRICTED RIGHTS LEGEND: 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 manual 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, nontrans- ferable, 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 implementa- tions of this specification that: (i) include a complete implementation of the current ver- sion of this specification without subsetting or supersetting; (ii) implement all the interfaces and functionality of the required packages of the Java™ 2 Platform, Standard Edition, as defined by SUN, without subsetting or supersetting; (iii) do not add any addi- tional packages, classes, or interfaces to the java.* or javax.* packages or their subpack- ages; (iv) pass all test suites relating to the most recent published version of the specification of the Java™ 2 Platform, Standard Edition, that are available from SUN six (6) months prior to any beta release of the clean room implementation or upgrade thereto; (v) do not derive from SUN source code or binary materials; and (vi) do not include any SUN source code or binary materials without an appropriate and separate license from SUN. Sun, Sun Microsystems, the Sun logo, Solaris, Java, JavaScript, JDK, and all Java-based trademarks or logos are trademarks or registered trademarks of Sun Microsystems, Inc. UNIX® is a registered trademark of The Open Group in the United States and other coun- tries. 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 TYPO- GRAPHICAL ERRORS. CHANGES ARE PERIODICALLY ADDED TO THE INFOR- MATION 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 PRO- GRAM(S) DESCRIBED IN THIS PUBLICATION AT ANY TIME. Credits and permissions for quoted material appear in a separate section on page 649. / vi Text printed on recycled and acid-free paper ISBN 0-321-24678-0 1 2 3 4 5 6 7 8 9-MA-99989796 First printing, May 2005 “When I use a word,” Humpty Dumpty said, in rather a scornful tone, “it means just what I choose it to mean—neither more nor less.” “The question is,” said Alice, “whether you can make words mean so many different things.” “The question is,” said Humpty Dumpty, “which is to be master—that’s all.” —Lewis Carroll, Through the Looking Glass [...]... and static imports have all been added to the language recently All but asserts are new to the 5.0 release of autumn 2004 This third edition of The Java™ Language Specification reflects these developments It integrates all the changes made to the Java programming language since the publication of the second edition in 2000 The language has grown a great deal in these past four years Unfortunately, it... California April, 2000 This is the FEMALE EDITION of the Dictionary The MALE edition is almost identical But NOT quite Be warned that ONE PARAGRAPH is crucially different The choice is yours.Milorad Pavic, Dictionary of the Khazars, Female Edition xxix Preface to the Third Edition This edition of the Java ™ Programming Language Specification represents the largest set of changes in the language s history Generics,... TO THE SECOND EDITION The specifications of the libraries are now far too large to fit into this volume, and they continue to evolve Consequently, API specifications have been removed from this book The library specifications can be found on the java.sun.com Web site (see below); this specification now concentrates solely on the Java programming language proper Readers may send comments on this specification. .. years, the Java ™ programming language has enjoyed unprecedented success This success has brought a challenge: along with explosive growth in popularity, there has been explosive growth in the demands made on the language and its libraries To meet this challenge, the language has grown as well (fortunately, not explosively) and so have the libraries This second edition of The Java™ Language Specification. .. compatibility This specification defines the language as it exists today The Java programming language is likely to continue to evolve At this writing, there are ongoing initiatives through the Java Community Process to extend the language with generic types and assertions, refine the memory model, etc However, it would be inappropriate to delay the publication of the second edition until these efforts... Specification reflects these developments It integrates all the changes made to the Java programming language since the publication of the first edition in 1996 The bulk of these changes were made in the 1.1 release of the Java platform in 1997, and revolve around the addition of nested type declarations Later modifications pertained to floating-point operations In addition, this edition incorporates... Statements 368 The Empty Statement 370 Labeled Statements 370 Expression Statements 371 The if Statement 372 14.9.1 The if–then Statement 372 14.9.2 The if–then–else Statement 372 The assert Statement 373 The switch Statement 377 The while Statement 380 14.12.1 Abrupt Completion 381 The do Statement 382 14.13.1 Abrupt Completion 383 14.13.2 Example of do statement 383 The for Statement 384 14.14.1 The basic... to download the latest J2SE release, visit http://java.sun.com Updated information about the Java Series, including errata for The Java™ Language Specification, Third Edition, and previews of forthcoming books, may be found at http://java.sun.com/Series This specification builds on the efforts of many people, both at Sun Microsystems and outside it The most crucial contribution is that of the people... to the design of the new language features across the board No one xxxi PREFACE TO THE THIRD EDITION deserves more credit for this version of the language than he - but any blame for its deficiencies should be directed at myself and the members of the many JSR expert groups! Neal has gone on in search of new challenges, and has been succeeded by Peter von der Ahé, who continues to improve and stengthen... myself! Many parts of the specification were developed by various expert groups in the framework of the Java community process The most pervasive set of language changes is the result of JSR-014: Adding Generics to the Java Programming Language The members of the JSR-014 expert group were: Norman Cohen, Christian Kemper, Martin Odersky, Kresten Krab Thorup, Philip Wadler and myself In the early stages, . The Java ™ Language Specification Third Edition The Java ™ Series The Java ™ Programming Language Ken Arnold, James Gosling and David Holmes ISBN 0-201-70433-1 The Java ™ Language Specification. or javax.* packages or their subpack- ages; (iv) pass all test suites relating to the most recent published version of the specification of the Java™ 2 Platform, Standard Edition, that are available. 368 14.6 The Empty Statement 370 14.7 Labeled Statements 370 14.8 Expression Statements 371 14.9 The if Statement 372 14.9.1 The if–then Statement 372 14.9.2 The if–then–else Statement 372 14.10 The