1. Trang chủ
  2. » Khoa Học Tự Nhiên

Java the complete reference 7th edition

1,1K 10 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1.058
Dung lượng 8,57 MB

Nội dung

www.elsolucionario.net www.elsolucionario.net www.elsolucionario.net Java : The Complete Reference, Seventh Edition www.elsolucionario.net ™ www.elsolucionario.net Herbert Schildt is a leading authority on the Java, C, C++, and C# languages, and is a master Windows programmer His programming books have sold more than 3.5 million copies worldwide and have been translated into all major foreign languages He is the author of the best-selling The Art of Java, Java: A Beginner’s Guide, and Swing: A Beginner’s Guide Among his other bestsellers are C++: The Complete Reference, C++: A Beginner’s Guide, C#: The Complete Reference, and C#: A Beginner’s Guide Schildt holds both graduate and undergraduate degrees from the University of Illinois He can be reached at his consulting office at (217) 586-4683 His Web site is www.HerbSchildt.com www.elsolucionario.net About the Author www.elsolucionario.net Java : The Complete Reference, Seventh Edition Herbert Schildt New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto www.elsolucionario.net ™ www.elsolucionario.net Copyright © 2007 by The McGraw-Hill Companies All rights reserved Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher ISBN: 978-0-07-163177-8 MHID: 0-07-163177-1 The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-226385-5, MHID: 0-07-226385-7 McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs To contact a representative please e-mail us at bulksales@mcgraw-hill.com Information has been obtained by McGraw-Hill from sources believed to be reliable However, because of the possibility of human or mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information TERMS OF USE This is a copyrighted work and The McGraw-Hill Companies, Inc (“McGrawHill”) and its licensors reserve all rights in and to the work Use of this work is subject to these terms Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hill’s prior consent You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited Your right to use the work may be terminated if you fail to comply with these terms THE WORK IS PROVIDED “AS IS.” McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE McGraw-Hill and its licensors not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom McGraw-Hill has no responsibility for the content of any information accessed through the work Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise www.elsolucionario.net All trademarks are trademarks of their respective owners Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark Where such designations appear in this book, they have been printed with initial caps www.elsolucionario.net Contents at a Glance 10 11 12 13 14 The History and Evolution of Java An Overview of Java Data Types, Variables, and Arrays Operators Control Statements Introducing Classes A Closer Look at Methods and Classes Inheritance Packages and Interfaces Exception Handling Multithreaded Programming Enumerations, Autoboxing, and Annotations (Metadata) I/O, Applets, and Other Topics Generics 15 33 57 77 105 125 157 183 205 223 255 285 315 Part II The Java Library 15 16 17 18 19 20 21 22 23 24 25 26 27 String Handling Exploring java.lang java.util Part 1: The Collections Framework java.util Part 2: More Utility Classes Input/Output: Exploring java.io Networking The Applet Class Event Handling Introducing the AWT: Working with Windows, Graphics, and Text Using AWT Controls, Layout Managers, and Menus Images The Concurrency Utilities NIO, Regular Expressions, and Other Packages 359 385 437 503 555 599 617 637 663 701 755 787 813 v www.elsolucionario.net Part I The Java Language www.elsolucionario.net Java: The Complete Reference Part III Software Development Using Java 28 29 30 31 Java Beans Introducing Swing Exploring Swing Servlets 847 859 879 907 Part IV Applying Java 32 Financial Applets and Servlets 33 Creating a Download Manager in Java A Using Java’s Documentation Comments 931 965 991 Index 997 www.elsolucionario.net vi www.elsolucionario.net Contents Preface xxix The History and Evolution of Java Java’s Lineage The Birth of Modern Programming: C C++: The Next Step The Stage Is Set for Java The Creation of Java The C# Connection How Java Changed the Internet Java Applets Security Portability Java’s Magic: The Bytecode Servlets: Java on the Server Side The Java Buzzwords Simple Object-Oriented Robust Multithreaded Architecture-Neutral Interpreted and High Performance Distributed Dynamic The Evolution of Java Java SE A Culture of Innovation 3 6 8 9 10 10 11 11 11 12 12 12 12 13 13 14 14 An Overview of Java Object-Oriented Programming Two Paradigms Abstraction The Three OOP Principles A First Simple Program Entering the Program Compiling the Program A Closer Look at the First Sample Program 15 15 15 16 16 21 21 22 22 vii www.elsolucionario.net Part I The Java Language www.elsolucionario.net Java: The Complete Reference A Second Short Program Two Control Statements The if Statement The for Loop Using Blocks of Code Lexical Issues Whitespace Identifiers Literals Comments Separators The Java Keywords The Java Class Libraries 24 26 26 27 29 30 30 30 31 31 31 31 32 Data Types, Variables, and Arrays Java Is a Strongly Typed Language The Primitive Types Integers byte short int long Floating-Point Types float double Characters Booleans A Closer Look at Literals Integer Literals Floating-Point Literals Boolean Literals Character Literals String Literals Variables Declaring a Variable Dynamic Initialization The Scope and Lifetime of Variables Type Conversion and Casting Java’s Automatic Conversions Casting Incompatible Types Automatic Type Promotion in Expressions The Type Promotion Rules Arrays One-Dimensional Arrays Multidimensional Arrays Alternative Array Declaration Syntax 33 33 33 34 35 35 35 35 36 36 36 37 38 39 39 40 40 40 40 41 41 42 42 45 45 45 47 47 48 48 51 55 www.elsolucionario.net viii www.elsolucionario.net Java: The Complete Reference Integer(s), 33, 34–36, 62–63 literals, 39–40 interface keyword, 183, 192 and annotations, 272 Interface(s), 183, 192–202 general form of, 193 implementing, 194–196 inheritance of, 202–203 member, 196 nested, 196–197 reference variables, 195–196, 200 variables, 193, 200–202 Internet, 3, 6, 7, 8, 15, 599 addresses, obtaining, 603 addressing scheme, 600 and portability, 7, 8, and security, 8–9 Internet Protocol (IP) addresses, 600 definition of, 599 InterNIC, 604, 605 InterruptedException, 218, 228, 768 Introspection, 848–850, 853 Introspector class, 851–852, 853 intValue( ), 265, 386, 387, 388, 391, 392, 393, 395 Investment, future value of an applet for finding, 940–943 formula to compute, 940 Investment required to achieve a future value applet for finding, 943–947 formula to compute, 944 invokeAndWait( ), 868, 873 invokeLater( ), 868, 873 I/O, 24, 285–296, 555–598 channel-based, 3, 815 classes, list of, 555–556 console, 24, 88, 285, 288–293 error handling, 296, 565 file, 293–296, 556–561 formatted See I/O, formatted interfaces, list of, 556 new See NIO streams See Stream(s) I/O, formatted, 525–549 format conversion specifiers See Format conversion specifiers using Formatter, 525–539 See also Formatter class using printf( ), 151, 539 using Scanner, 540–549 See also Scanner class io package See java.io package IOError, 587 IOException, 289, 294, 295, 562, 564, 565, 566, 572, 579, 581, 585, 593, 595, 612, 818 IPv4 (Internet Protocol, version 4), 600, 601 IPv6 (Internet Protocol, version 6), 600, 601 isAbsolute( ), 558 isAlive( ), 226, 234–236, 424 isAltDown( ), 644 isAltGraphDown( ), 644 isAnnotationPresent( ), 278, 280, 430 isBound( ), 604, 614, 854 isClosed( ), 604 isConnected( ), 604, 614 isConstrained( ), 854 isControlDown( ), 644 isDigit( ), 399, 401 isDirectory( ), 559 isEditable( ), 720, 722 isEmpty( ), 376, 441, 442, 465, 489, 493, 494, 495, 505 isEnabled( ), 737 isFile( ), 558 isHidden( ), 559 isInfinite( ), 387, 389, 390 isLeapYear( ), 512–513 isLetter( ), 399, 401 isMetaDown( ), 644 isMulticastAddress( ), 602 isNaN( ), 388, 389, 390 isPopupTrigger( ), 646–647 isPublic( ), 816, 835 isSelected( ), 886, 888, 890 isSet, 509 isShiftDown( ), 644 isTemporary( ), 643 isTimeSet, 509 ItemEvent class, 640, 644–645, 707, 711, 714, 738, 886, 888 ItemListener interface, 650, 651, 707, 711, 738, 886, 888 ItemSelectable interface, 645 itemStateChanged( ), 651, 707, 711, 869, 886, 888 Iterable interface, 434, 441, 461, 464, 488 Iteration statements, 77, 84–98 Iterator, 438, 440, 458–462 and maps, 464 Iterator interface, 438, 440, 458–459, 460, 486 methods, table of, 459 iterator( ), 434, 441, 442, 459, 460 www.elsolucionario.net 1010 www.elsolucionario.net J J2SE 5, new features of, 13–14 Jakarta Project, 908 JApplet class, 617, 863, 871, 873 JAR files, 550 Java API packages, table of core, 813–815 and C, 3, 5, 7, 11 and C++, 3, 7, 11 and C#, design features (buzzwords), 10–13 history of, 3, 6–8, 13–14 and the Internet, 3, 6, 7–9, 12, 14, 599, 601, 965 as interpreted language, 9, 10, 12 keywords, 31–32 as strongly typed language, 10, 11, 33 versions of, 13–14 and the World Wide Web, 6, Java Archive (JAR) files, 550 Java Beans, 417, 436, 813, 833, 847–857 advantages of, 848 API, 851–854 customizers, 851 demonstration program, 854–857 introspection, 848–850 serialization, 851 Java Community Process (JCP), 14 java filename extension, 21 Java Foundation Classes (JFC), 860 java (Java application launcher) See Application launcher (java) Java Native Interface (JNI), 303 java package, 191 Java SE (Java Platform, Standard Edition 6), 14 Java Virtual Machine (JVM), 9–10, 12, 13, 14, 22, 23, 404, 422 java.applet package, 617 java.awt package, 637, 640, 664, 755, 870 classes, tables of some, 664–665 java.awt.Dimension class, 833 java.awt.event package, 637, 639, 640, 650, 659, 868, 870 event classes, table of, 640 java.awt.image package, 755, 765, 770, 786 java.beans package, 850, 851–854 classes, table of, 852–853 interfaces, tables of, 852 java.io package, 285, 286, 555–556, 825 java.io.Externalizable interface, 851 java.io.IOException, 88 java.io.Serializable interface, 851 java.lang package, 191, 217, 273, 282, 288, 359, 385–436 classes and interfaces, list of, 385 java.lang.annotation package, 272, 282, 435 java.lang.annotation.RententionPolicy enumeration, 273 java.lang.image package, 767 java.lang.instrument package, 435 java.lang.management package, 435 java.lang.ref package, 435 java.lang.reflect package, 273, 278, 436, 813, 814, 833 classes, table of, 834 java.net package, 599, 612 classes and interfaces, list of, 600–601 java.nio package, 433, 555, 813, 814, 815 java.nio.channels package, 814, 815, 818, 819 java.nio.channels.spi package, 814, 815 java.nio.charset package, 814, 815, 818 java.nio.charset.spi package, 814, 815 java.rmi package, 813, 814, 837 java.text package, 813, 815, 840 java.util package, 437–438, 503, 637, 639 java.util.concurrent package, 554, 788, 806 java.util.concurrent.atomic package, 554, 788, 789, 811 java.util.concurrent.locks package, 554, 788, 789, 808, 809, 811 java.util.jar package, 554 java.util.logging package, 554 java.util.prefs package, 554 java.util.regex package, 554, 813, 815, 825 java.util.spi package, 554 java.util.zip package, 554 javac (Java compiler), 22 javadoc utility program, 991, 995 javah.exe, 304, 305 javax.imageio package, 786 javax.servlet package, 911–915 interfaces and classes, list of, 911, 912 javax.servlet.http package, 911, 917–922 interfaces and classes, list of, 917 javax.swing package, 862, 864, 865, 879, 901 javax.swing.event package, 868, 881, 896, 901 javax.swing.table package, 904 javax.swing.tree package, 901 JButton class, 863, 870, 883–885 JCheckBox class, 885, 887–889 1011 www.elsolucionario.net Index www.elsolucionario.net Java: The Complete Reference JComboBox class, 898–900 JComponent class, 862, 863, 871, 873, 875, 879 JDialog class, 863 JDK (Java SE Development Kit), 21 JFrame class, 863, 864, 866, 867, 877 JIT (Just-In-Time) compiler, 10 JLabel class, 864, 866, 879–881 JLayeredPane class, 863 JList class, 895–898 jni.h, 305 jni_md.h, 305 join( ), 226, 234–236, 424 Joy, Bill, JPanel class, 863, 877, 891 JPEG image format, 755–756 JRadioButton class, 885, 889 JRootPane class, 863 JScrollBar class, 863 JScrollPane class, 893–895, 896, 901, 904 JTabbedPane class, 891–893 JTable class, 904–906 JTextComponent class, 881 JTextField class, 881–882 JToggleButton class, 885–887, 889 JToggleButton.ToggleButtonModel class, 886 JTree class, 900–903 Jump statements, 77, 98–104 Just In Time (JIT) compiler, 10 JVM (Java Virtual Machine), 9–10, 12, 13, 14, 22, 23, 404, 422 JWindow class, 863 K Kernighan, Brian, Key codes, virtual, 645, 657 KeyAdapter class, 659, 660 Keyboard events, handling, 656–658 KeyEvent class, 640, 642, 643, 645 KeyListener interface, 650, 651–652, 656 keyPressed( ), 651–652, 656, 657 keyReleased( ), 651–652, 656 keys( ), 493, 494, 495 keySet( ), 465, 497, 612 keyTyped( ), 651–652, 656, 657 Keywords, table of Java, 32 L Label AWT standard control, 702–703 Swing, 864 used with break statement, 100, 102–103 Label class, 702–703 last( ), 444, 730 lastElement( ), 488, 489 lastIndexOf( ), 370–372, 383, 443, 488, 489 lastKey( ), 465, 466 Late binding, 180 Layered pane, 863 Layout managers, 666, 701, 723–736 LayoutManager interface, 723 length instance variable of arrays, 143–145 length( ), 149–150, 362, 378, 433, 505 Lexer, 503 Libraries, class, 21, 32 Lightweight components, 860 containers, 863 Lindholm, Tim, LineNumberInputStream deprecated class, 556 LineNumberReader class, 288 LinkedBlockingDeque class, 808 LinkedBlockingQueue class, 808 LinkedHashMap class, 468, 471–472 LinkedHashSet class, 448, 454 LinkedList class, 448, 451–453 List class, 713 extending, 752–753 List controls, 713–715 List interface, 440, 441–443, 451, 453, 460, 488 methods, table of, 443 List, Swing, 895–908 list( ) and directories, 556, 559–561 listFiles( ), 561 ListIterator interface, 440, 458–459, 486 methods, table of, 459 listIterator( ), 443, 460 ListModel, 896 ListResourceBundle class, 551 ListSelectionEvent class, 896, 904 ListSelectionListener interface, 896 ListSelectionModel, 896, 904 Literals, 31, 39–41 class, 275 regular expression, 827 string, 362 Loan balance, applet to find, 955–959 Loan payments applet to compute, 932–939 formula for calculating, 932 servlet to compute, 959–963 load( ), 404, 410, 498, 500–501 loadLibrary( ), 304, 404, 410 Locale class, 376, 515–516, 840, 841 www.elsolucionario.net 1012 www.elsolucionario.net Lock interface, 789, 808 methods, table of, 809 lock( ), 789, 808, 809 lockInterruptibly( ), 809 Locks, 808–811 log( ) math method, 419 servlet method, 913, 914 log10( ), 419 log1p( ), 419 Logical operators bitwise, 63–65 Boolean, 71–73 long, 33, 34, 35–36 literal, 40 Long class, 265, 390, 396, 397 methods, table of, 395 longValue( ), 265, 386, 388, 389, 391, 392, 393, 395 Look and feels, 861 lookup( ), 838 loop( ), 635 Loop(s) do-while, 86–88 for See for loop infinite, 92 nested, 97–98, 99–100, 101 with polling, event, 224, 242–243 while, 84–86 Low surrogate char, 401 M main( ), 23–24, 106, 138, 141 and applets, 24, 297, 299, 617 and the java application launcher, 23–24 and command-line arguments, 24, 150–151 and Swing programs, 867–868 and windowed applications, 676 main (default name of main thread), 227 MalformedURLException, 606 Map interface, 464–465, 467, 468, 472, 493, 494 methods, table of, 465 map( ), 818, 821, 823 Map(s), 439, 464–472 classes, 468–472 interfaces, 464–467 Map.Entry interface, 464, 467 methods, table of, 467 MappedByteBuffer class, 817, 821 mark( ), 562, 563, 564, 567, 570, 572, 580, 584, 816 markSupported( ), 562, 563, 570, 572, 579, 580, 584 Matcher class, 825, 826–827 matcher( ), 826 matches( ), 376, 826, 828, 833 Math class, 42, 128, 418–421 rounding methods, table of, 420 and static import example, 309–311 max( ), 420, 477, 480 MAX_EXPONENT, 387 MAX_PRIORITY, 236, 422 MAX_RADIX, 398 MAX_VALUE, 387, 391, 398 MediaTracker class, 665, 755, 762–765 Member, class, 17, 106 access and inheritance, 159–160 access, table of, 187 static, 141 Member interface, 436, 833 Memory allocation using new, 49, 50, 109–110 management, in Java, 12 and Runtime class, 405–406 MemoryImageSource class, 765–767, 770 Menu bars and menus, 701, 737–742 action command string of, 738 Menu class, 737, 738 MenuBar class, 737, 738 MenuItem class, 737, 738 MessageFormat class, 525 Metadata, 272 See also Annotation(s) Method class, 274, 277, 278, 436, 833–834, 835, 854 Method(s), 17, 106, 111–120 abstract, 177–180 and autoboxing, 267–268 calling, 113, 115 dispatch, dynamic, 174–177 and the dot (.) operator, 107, 114 factory, 601 final, 143, 180 general form, 112 generic, 316, 334–336, 355 getter, 848 hidden, using super to access, 166–167, 172 interface, 193, 194 native, 302–306 1013 www.elsolucionario.net Index www.elsolucionario.net Java: The Complete Reference overloading, 125–130, 154–156, 173 overriding See Overriding, method and parameters, 112, 115–117 passing object to, 133–134 recursive, 135–137 resolution, dynamic, 193 returning object from, 134–135 returning a value from, 114–115 scope defined by, 43–45 setter, 848 static, 141–143 synchronized, 225, 239–241 varargs See Varargs MethodDescriptor class, 850, 851, 853, 854 MIME (Multipurpose Internet Mail Extensions), 611, 612, 907, 910 min( ), 420, 477, 480 minimumLayoutSize( ), 723 MIN_EXPONENT, 387 MIN_NORMAL, 387 MIN_PRIORITY, 236, 422 MIN_RADIX, 398 MIN_VALUE, 387, 391, 398 mkdir( ), 561 mkdirs( ), 561 Model-Delegate architecture, 861–862 Model-View-Controller (MVC) architecture, 861 Modifier class, 835 methods, table of, 836 Modulus operator (%), 57, 59 Monitor, 225, 238, 239 Mouse events, handling, 653–656 MouseAdapter class, 659 mouseClicked( ), 652, 659 mouseDragged( ), 652, 659 mouseEntered( ), 652 MouseEvent class, 640, 642, 643, 646–647 mouseExited( ), 652 MouseListener interface, 650, 652, 653 MouseMotionAdapter class, 659 MouseMotionListener interface, 639, 650, 652, 653, 659 mouseMoved( ), 652, 659 mousePressed( ), 652 mouseReleased( ), 652 MouseWheelEvent class, 640, 647–648 MouseWheelListener interface, 650, 652, 653 mouseWheelMoved( ), 652 Multitasking, 223, 225 Multithreaded programming, 7, 11, 12, 223–254 context switching See Context switching effectively using, 254 Observable class, Observer interface and, 522 and spurious wakeup, 243 and StringBuilder class, 384 and synchronization See Synchronization and threads See Thread(s) versus the concurrency utilities, 787, 812 versus single-threaded system, 224 MutableComboBoxModel, 899 MutableTreeNode interface, 901 Mutex, 238 MVC (Model-View-Controller) architecture, 861 N NAME, 629 Name-space collisions between instance variables and local variables, 121 packages and, 183–184, 312 name( ), 433 Naming class, 837, 838 NaN, 387, 390 nanoTime( ), 410, 411 native modifier, 302–303 Natural ordering, 433, 472 Naughton, Patrick, NavigableMap interface, 464, 466, 470 methods, table of, 466–467 NavigableSet interface, 440, 444–445, 455, 456 methods, table of, 445 Negative numbers in Java, representation of, 62, 63 NEGATIVE_INFINITY, 387 NegativeArraySizeException, 218, 481 Net Framework, Networking, 599–616 basics, 599–600 classes and interfaces, list of, 600–601 new, 49, 50, 109–110, 117, 119, 121, 135, 178 autoboxing and, 267 and enumerations, 256, 259 New I/O See NIO newCachedThreadPool( ), 802 newCondition( ), 808, 809 newFixedThreadPool( ), 802 newScheduledThreadPool( ), 802 www.elsolucionario.net 1014 www.elsolucionario.net next( ), 459, 460, 730 nextAfter( ), 420 nextBoolean( ), 517 nextBytes( ), 517 nextDouble( ), 202, 517, 545, 547 nextElement( ), 487, 504 nextFloat( ), 517 nextGaussian( ), 517 nextInt( ), 517 nextLong( ), 517 nextToken( ), 504, 591 nextUp( ), 420 nextX( ) Scanner methods, 541, 543, 545, 547 table of, 543 NIO, 813, 815–825 copying a file using, 824–825 packages, list of, 815 reading a file using, 819–822 writing to a file using, 822–824 NORM_PRIORITY, 236, 422 NoSuchElementException, 444, 446, 465, 543, 549 NoSuchFieldException, 218 NoSuchMethodException, 218, 274 NOT operator bitwise unary (~), 62, 63, 64–65 Boolean logical unary (!), 71, 72 notepad, 406–407, 408 notify( ), 181, 243, 245–246, 252, 413, 808 notifyAll( ), 181, 243, 413 notifyObservers( ), 518, 519 NotSerializableException, 596 null, 32 Null statement, 85 NullPointerException, 214, 218, 441, 443, 444, 445, 446, 458, 464, 465, 466, 481, 494, 550 Number class, 265, 386 NumberFormat class, 525, 840 NumberFormatException, 218, 266, 631 O Oak, Object class, 181–182, 292, 316, 412 as data type, problems with using, 320–322, 485 methods, table of, 181, 412–413 Object reference variables assigning, 111 declaring, 109 and cloning, 413 and dynamic method dispatch, 174–177 interface, 195–196 to superclass reference variable, assigning subclass, 162 OBJECT tag, 618, 630 Object-oriented programming (OOP), 5, 6, 15–21 model in Java, 11 Object(s), 17, 105, 110 bitwise copy (clone) of, 413 creating, 107, 109–110 initialization with constructor, 117, 119 to method, passing, 133–134 monitor, implicit, 225, 239 as parameters, 130–132 returning, 134–135 serialization of See Serialization type at run time, determining, 300–302 Object.notify( ), 808 Object.wait( ), 808 ObjectInput interface, 595 methods defined by, table of, 595 ObjectInputStream class, 287, 595 methods defined by, table of, 596 ObjectOutput interface, 593 methods defined by, table of, 594 ObjectOutputStream class, 287, 593 methods defined by, table of, 594 Observable class, 518–522 methods, table of, 519 Observer interface, 518, 519–522 Octals, 40 as character values, 41 of( ), 458 offer( ), 446, 456 offerFirst( ), 446, 447, 452 offerLast( ), 446, 447, 452 offsetByCodePoints( ), 376, 383 openConnection( ), 607, 608, 610 Operator(s) arithmetic, 57–62 assignment See Assignment operator(s) bitwise, 62–70 Boolean logical, 71–73 parentheses and, 74–75 precedence, table of, 75 relational, 39, 70–71 ternary, 73–74 OR operator (|) bitwise, 62, 63, 64–65 Boolean, 71, 72 1015 www.elsolucionario.net Index www.elsolucionario.net Java: The Complete Reference OR operator, short-circuit (||), 71, 72–73 Ordinal value, 261 ordinal( ), 261, 262, 433 out output stream, 24, 288, 407, 409 out( ), 527, 529 OutputStream class, 286, 287, 292, 562, 565, 571, 574, 576, 586, 593 methods, table of, 563 OutputStreamWriter class, 288 Overloading methods, 125–130, 154–156, 173 @Override, built-in annotation, 282, 283 Overriding, method, 171–177 and dynamic method dispatch, 174–177 using final to prevent, 180 P Package(s), 138, 183–192, 202 access to classes contained in, 186–190 core Java API, table of, 813–815 defining, 184 finding, 184–185 importing, 190–192 Swing, 863–864 Package class, 278, 429–430 methods, table of, 430 package statement, 184, 190 Paint mode, setting, 685–686 paint( ), 297, 621, 622, 623, 624, 625, 626, 670, 676, 758, 871, 874 Paintable area, computing, 875 paintBorder( ), 874 paintChildren( ), 874 paintComponent( ), 874, 878 Painting in Swing, 873–878 Panel class, 618, 665, 666, 667, 730 Panes, top-level Swing container, 863 PARAM NAME, 630 Parameter(s), 24, 43, 112, 115–117 applets and, 630–633 and constructors, 119–120 objects as, 130–132 and overloaded constructors, 130 and overloaded methods, 125 type See Type parameter(s) Parameterized types, 316, 317 parseByte( ), 391, 396–397 parseInt( ), 394, 396–397 parseLong( ), 396–397 parseShort( ), 392, 396–397 Parsing, 503 Pascal, Passwords, reading, 587 Pattern class, 825–826 Pattern matching See Regular expressions PatternSyntaxException, 827 Payne, Jonathan, peek( ), 446, 491, 492 peekFirst( ), 447, 452 peekLast( ), 447, 452 Peers, native, 859, 860 Persistence (Java Beans), 851 PI (double constant), 418 PipedInputStream class, 287 PipedOutputStream class, 287 PipedReader class, 288 PipedWriter class, 288 PixelGrabber class, 767–769, 770 play( ), 619, 635 Pluggable look and feel (PLAF), 860–861, 862 PNG file format, 756, 757 Point class, 646, 647 Pointers, 56, 109 poll( ), 446, 456 pollFirst( ), 447, 452 Polling, 224, 242–243 pollLast( ), 447, 452 Polygon class, 665, 681 Polymorphism, 19–21 and dynamic method dispatch, 174–177 and interfaces, 192, 195–196, 200 and overloaded methods, 125, 127, 128 pop( ), 446, 447, 491, 492 PopupMenu class, 742 Port, 599 Portability problem, 6–7, 8, 9, 12, 14 and data types, 34 and native methods, 306 and thread context switching, 225 POSITIVE_INFINITY, 387 pow( ), 309–311, 419 preferredLayoutSize( ), 723 previous( ), 459, 730 print( ), 26, 292, 364, 574, 587, 915 printf( ) function, C/C++, 525 method, Java, 151, 539, 575–576, 586, 587 println( ), 24, 26, 292, 364, 574, 575, 586, 587, 588, 915 printStackTrace( ), 219 PrintStream class, 287, 288, 292, 574–576 PrintWriter class, 288, 292–293, 586–587 www.elsolucionario.net 1016 www.elsolucionario.net Index Q Query string, 923 Queue interface, 445–446, 451, 456 methods, table of, 446 R Race condition, 240–241 Radio buttons, 709 Swing, 889–891 Radix, 390 radix( ), 549 Random class, 202, 516–518 methods, table of, 517 random( ), 421 RandomAccess interface, 440, 463 RandomAccessFile class, 287, 578, 818, 823 range( ), 458 Raw types, 339–342, 487 and erasure, 351 read( ), 286, 289–290, 294–295, 434–435, 563, 570, 572, 580, 585 595, 596, 818, 819, 820 and end-of-file condition, 296 Readable interface, 434–435, 540, 579 ReadableByteChannel interface, 540 readBoolean( ), 577 readDouble( ), 577, 596 Reader class, 286, 289, 562, 579, 590 methods defined by, table of, 580 readExternal( ), 593 readInt( ), 577, 596 readLine( ), 290–291, 397, 587, 588, 915 readObject( ), 595, 596 readPassword( ), 587, 588 ReadWriteLock interface, 811 rebind( ), 837 receive( ), 613 Recursion, 135–137 ReentrantLock, 809 ReentrantReadWriteLock, 811 Reflection, 273, 436, 813, 833–836 regionMatches( ), 367–368 Regular expressions, 377, 541, 813, 825–833 syntax, 827 wildcards and quantifiers, 825, 827, 829–831 Relational operators, 39, 70–71 release( ), 790–793 Remote interface, 837 Remote method invocation (RMI), 12, 592, 813, 837–840 www.elsolucionario.net PriorityBlockingQueue class, 808 PriorityQueue class, 448, 456 private access specifier, 23, 138–140, 186–187 and inheritance, 159–160 Process class, 403, 406, 407 methods, table of, 403 Process-based versus thread-based multitasking, 223 processActionEvent( ), 750, 753 processAdjustmentEvent( ), 749, 753 ProcessBuilder class, 403, 407–408 methods, table of, 408 processComponentEvent( ), 749 processFocusEvent( ), 749 processItemEvent( ), 749, 750, 752, 753 processKeyEvent( ), 749 processMouseEvent( ), 749 processMouseMotionEvent( ), 749 processMouseWheelEvent( ), 749 processTextEvent( ), 749 Programming multithreaded See Multithreaded programming object-oriented See Object-oriented programming (OOP) structured, Properties class, 438, 487, 497–501 methods, table of, 498 Properties, environment, 412 Property, Java Bean, 848–849 bound and constrained, 850–851 PropertyChangeEvent, 850–851 PropertyChangeListener interface, 851 PropertyDescriptor class, 850, 851, 853, 854, 855–856 PropertyPermission class, 553 PropertyResourceBundle class, 550–551 PropertyVetoException, 851 protected access specifier, 122, 138, 187 public access specifier, 23, 138–139, 186–187 Push buttons, 620, 704–707 action command string of, 704, 705, 707 Swing, 870 push( ), 446, 447, 491, 492 Pushback, 571 PushbackInputStream, 287, 569, 571–572 PushbackReader class, 288, 585–586 put( ), 464, 465, 468, 472, 493, 494, 495 and buffers, 817, 823 putAll( ), 465, 472 PutField inner class, 593 1017 www.elsolucionario.net Java: The Complete Reference RemoteException, 837 remove( ), 441, 442, 443, 446, 453, 459, 465, 493, 494, 495, 702, 867 removeActionListener( ), 870 removeAll( ), 441, 442, 702 removeAttribute( ), 919, 927 removeEldestEntry( ), 472 removeElement( ), 488, 489 removeElementAt( ), 488, 489 removeFirst( ), 447, 452 removeLast( ), 447, 452 removeTListener( ), 850 removeTypeListener( ), 639 renameTo( ), 558 repaint( ), 625–626, 670, 874 demonstration program, 626–628 replace( ), 373, 382–383 replaceAll( ), 376, 826–827, 831–832 replaceFirst( ), 376 replaceRange( ), 722 ReplicateScaleFilter class, 770 reset( ), 549, 563, 564, 567, 570, 572, 580, 584, 816 resetSyntax( ), 590 Resource bundles, 549–553 ResourceBundle class, 549–550 methods, table of, 550–551 ResourceBundle.Control class, 550 resume( ), 13, 249–252, 423, 429 retainAll( ), 441, 442 @Retention built-in annotation, 273, 282 RetentionPolicy enumeration, 273, 435 return statement, 103–104, 112 reverse( ), 381, 394, 396 reverseBytes( ), 392, 394, 396 reverseOrder( ), 477, 479 rewind( ), 816, 820, 823 RGB (red-green-blue) color model, default, 683, 766 RGBImageFilter class, 770, 772–782 RGBtoHSB( ), 683 Richards, Martin, rint( ), 420 Ritchie, Dennis, RMI compiler (rmic), 839 rmiregistry (RMI registry), 839 round( ), 420 Run-time system, Java, See also Java Virtual Machine (JVM) type information, 13, 300, 417 run( ), 226, 228, 422, 424, 522 overriding, 230, 232, 522 using flag variable with, 252–253 Runnable interface, 226, 422, 522, 868 implementing, 228–230, 232 Runtime class, 403, 404–407 executing other programs and, 406–407 memory management and, 405–406 methods, table of, 404–405 RUNTIME retention policy, 273, 274, 277 RuntimeException class, 206, 215, 217, 221 RuntimePermission class, 431 S save( ), 497 scalb( ), 419 Scanner class, 540–549 constructors, 540–541 delimiters, 547–548 demonstration programs, 544–547 hasNextX( ) methods, table of, 542 how to use, 541–543 methods, miscellaneous, 548–549 nextX( ) methods, table of, 543 schedule( ), 523 ScheduledExecutorService interface, 802 ScheduledThreadPoolExecutor class, 788, 802 Scientific notation, 40 Scopes in Java, 42–45 Scroll bars, 716–718 Scroll pane, 893–895 Scrollbar class, 716–717 extending, 753–754 search( ), 491, 492 Security problem, 8, 9–10, 14 and native methods, 306 and servlets, 908 SecurityException, 218, 404, 409 SecurityManager class, 431 seek( ), 578 select( ), 711, 714, 719, 722 Selection statements, 77–84 Selectors, 818, 819 Semaphore, 238 and setting initial synchronization state, 795 using, 789–795 Semaphore class, 788, 789–790 send( ), 613 Separable Model architecture, 861 www.elsolucionario.net 1018 www.elsolucionario.net Separators, 31 SequenceInputStream class, 287, 573–574 Serializable interface, 593 Serialization, 592–598 example program, 595–598 and Java Beans, 851 and static variables, 593 and transient variables, 593, 597 Server, 599 proxy, 601, 611, 630 ServerSocket class, 603, 612–613, 818 ServiceLoader class, 553 service( ), 908, 910, 912, 913 Servlet interface, 911, 912 methods, table of, 913 Servlet(s), 10, 14, 907–928 advantages of, 908 API, 911 example of simple, 910–911 financial calculation example, 959–963 life cycle of, 908 parameters, reading, 915–916 and portability, 10 and security, 908 and session tracking, 927–928 using Tomcat to develop, 908–909 ServletConfig interface, 911, 912 ServletContext interface, 911, 912 methods, table of, 913 ServletException class, 912, 915 ServletInputStream class, 912, 915 ServletOutputStream class, 912, 915 ServletRequest interface, 910, 911, 913, 915 methods, table of, 914 ServletResponse interface, 910, 911, 913 methods, table of, 914 Session tracking, 927–928 Set interface, 440, 443–444, 453, 458, 464, 467 Set-view, obtaining, 465, 468, 469, 496 set( ), 443, 453, 459, 506, 510, 811 setActionCommand( ), 707, 738, 883, 890 setAddress( ), 615 setAlignment( ), 703 setAttribute( ), 913, 919, 927 setBackground( ), 623, 683 setBlockIncrement( ), 717 setBorder( ), 877 setBounds( ), 667, 723 setChanged( ), 518, 519 setCharAt( ), 379 setColor( ), 684 setConstraints( ), 733 setContentType( ), 910 setData( ), 615 setDefault( ), 514, 516 setDefaultCloseOperation( ), 866 setDisabledIcon( ), 883 setEchoChar( ), 720 setEditable( ), 720, 722, 937 setEnabled( ), 737 setFollowRedirects( ), 610 setFont( ), 689 setForeground( ), 623, 683 setIcon( ), 880 SetIntField( ), 305 setLabel( ), 704, 707, 737 setLastModified( ), 559 setLayout( ), 723, 867 setLength( ), 378–379, 578, 615 setLocation( ), 667 setMaxAge( ), 920, 927 setName( ), 227, 228, 424 setPaintMode( ), 685 setPort( ), 615 setPreferredSize( ), 667 setPressedIcon( ), 883 setPriority( ), 236, 424 setReadOnly( ), 559 setRequestMethod( ), 610 setRolloverIcon( ), 883 setSelectedCheckbox( ), 709 setSelectedIcon( ), 883 setSelectionMode( ), 896 setSize( ), 489, 667, 668, 669, 866 setSoTimeout( ), 614 setStackTrace( ), 219 setState( ), 707, 738 setStream( ), 635 setText( ), 703, 719, 722, 880, 883, 937 setTitle( ), 668 setUnitIncrement( ), 717 setValue( ), 467, 716–717, 920 setValues( ), 716 setVisible( ), 668, 669, 867 setXORMode( ), 685 Sheridan, Mike, Shift operators, bitwise, 62, 65–69 Short class, 265, 390, 396, 397 methods defined by, table of, 392 short data type, 33, 34, 35, 40 shortValue( ), 265, 386, 388, 389, 391, 392, 394, 396 1019 www.elsolucionario.net Index www.elsolucionario.net Java: The Complete Reference show( ), 730 showDocument( ), 633, 634, 635 showStatus( ), 620, 628, 635 shuffle( ), 477, 479 shutdown( ), 801, 804 Sign extension, 67 signal( ), 808 signum( ), 394, 396, 421 SimpleBeanInfo class, 850 SimpleDateFormat class, 516, 842–843 formatting string symbols, table of, 843 SimpleTimeZone class, 514–515 sin( ), 418 SingleSelectionModel, 891 sinh( ), 419 SIZE, 387, 391 size( ), 441, 442, 453, 465, 489, 493, 494, 495, 506, 819 skip( ), 549, 563, 564–565, 570, 580, 595 sleep( ), 226, 227, 228, 233, 424, 807 slice( ), 817 Slider box, 716 Socket class, 603–605, 612, 613, 818 Socket(s) example program of client/server, 611–628 overview, 599 TCP/IP client, 603–605 TCP/IP server, 603, 612–613 SocketAddress class, 613 SocketChannel class, 818 SocketException, 613 sort( ), 482–483 SortedMap interface, 464, 465, 466 methods, table of, 466 SortedSet interface, 440, 444 methods, table of, 444 Source code file, naming, 21–22 SOURCE retention policy, 273 split( ), 376, 377, 832 sqrt( ), 42, 309–311, 419 Stack definition of, 123 ways to implement a, 197 Stack class, 438, 448, 487, 491–493 methods, table of, 492 Stack frame, 431 Stack trace, 207, 441 StackTraceElement class, 431–432 methods, table of, 431–432 Standard Template Library (STL), 439 start( ), 226, 229, 230, 403, 408, 424, 620, 621, 622, 623, 624, 669, 826, 871 startsWith( ), 368 Statements, 24 null, 85 Statements, control iteration, 77, 84–98 jump, 77, 98–104 selection, 77–84 static, 23, 141–143, 145, 309 member restrictions, 354–355 Static import, 14, 309–312 stop( ), 13, 251–252, 423, 620, 621, 622–623, 625, 635, 669, 871 store( ), 498, 500–501 Stream(s) benefits, 598 buffered, 569–572 classes, byte, 286, 287, 562–578 classes, character, 286, 287–288, 562, 578–592 definition of, 286, 555 filtered, 569 predefined, 288 StreamTokenizer class, 590–592 strictfp, 302 StrictMath class, 422 String class, 24, 55–56, 148–150, 359, 433, 540 constructors, 359–362 String(s) arrays of, 150 changing case of characters in, 375–376 comparison, 366–370 concatenating, 148–149, 362–364 373, 380 creating, 359–362 extracting characters from, 365–366 length, obtaining, 149–150, 362 literals, 40–41, 362 modifying, 372–374 as objects, 41, 55–56, 148, 359 parsing a formatted input, 503 reading, 290–291 representations of numbers, converting, 390, 396–398 searching, 370–372 StringBuffer class, 148, 359, 361, 372, 377–384, 433 StringBufferInputStream deprecated class, 556 StingBuilder class, 359, 361, 372, 384, 433, 526 and synchronization, 384 www.elsolucionario.net 1020 www.elsolucionario.net StringIndexOutOfBounds exception, 218 StringReader class, 288 StringWriter class, 288 StringTokenizer class, 503–504 methods, table of, 504 stringWidth( ), 692, 693 Stroustrup, Bjarne, Stubs (RMI), 838 Subclass, 18, 157, 158, 159, 175 subList( ), 443 subMap( ), 465, 466 submit( ), 804 subSequence( ), 377, 384, 433 subSet( ), 444, 445, 456 substring( ), 372–373, 383 Sun Microsystems, 6, 599 super, 141 and bounded wildcard arguments, 334 and methods or instance variables, 166–167, 172 super( ), 314 and superclass constructors, 163–166, 170 Superclass, 18, 157, 158, 159, 175 Supplemental character, definition of, 401 @SuppressWarnings built-in annotation, 282, 283 suspend( ), 13, 249–252, 423, 429 Swing, 13, 285, 299, 617, 663, 859–878, 879–906 applet, example of a simple, 871–873 application, example of a simple, 864–868 and the AWT, 663, 859, 860 component classes, list, 862 download manger using, 965–990 event handling, 868–871 history of, 859–860 and MVC architecture, 861 packages, list of, 864 and painting, 873–878 threading issues, 867–868, 871 Swing: A Beginner’s Guide (Schildt), 859 SwingConstants interface, 880 SwingUtilities class, 868 switch statement, 80–84 and auto-unboxing, 269–270 using enumeration constants to control, 81, 256–257 Synchronization, 12, 225, 238–242 and atomic operations, 811–812 and collections, 448, 479, 487 and deadlock, 247–249, 251 objects, using, 789–801 race condition and, 240–241 and StringBuilder class, 384 via synchronized block, 241–242, 479 via synchronized method, 239–241 versus concurrency utilities, 787, 812 synchronized modifier, 239 used with method, 239, 240–241 used with object, 241–242 synchronizedList( ), 478, 479 synchronizedSet( ), 478, 479 Synchronizers, 788 SynchronousQueue class, 808 System class, 24, 288, 409–412 methods, table of, 409–410 System.console( ), 409, 587 System.err standard error stream, 288 System.getProperties( ), 409, 497 System.in standard input stream, 288, 289, 541, 587 System.in.read( ), 88 System.out standard output stream, 24, 288, 292, 293, 539, 574, 575, 587 T Tabbed panes, 891–893 TableColumnModel, 904 TableModel, 904 TableModelEvent class, 904 tailMap( ), 465, 466 tailSet( ), 444 tan( ), 418 tanh( ), 419 @Target built-in annotation, 282–283 TCP/IP, 12, 599–600 client sockets, 603–605 disadvantages of, 613 server sockets, 603, 612–613 See also Transmission Control Protocol (TCP) Templates, C++, 316 Ternary operator (?:), 71, 73–74 Text area, 721–723 Text fields, 719–721, 937 Swing, 881–882, 937 Text formatting using java.text classes, 813, 840–843 Text output, managing, 691–699 TextArea class, 721–723 textChanged( ), 652 TextComponent class, 719, 722 TextEvent class, 640, 648 1021 www.elsolucionario.net Index www.elsolucionario.net Java: The Complete Reference TextField class, 719 TextListener interface, 650, 652 this, 120–121, 141 this( ), 312–314 Thompson, Ken, Thread class, 13, 226, 422–424, 522 constructors, 229, 231, 422 extending, 230–232 methods, table of, 423–424 Thread(s) creating, 228–233 daemon, 522 and deadlock, 247–249, 251 definition of, 223 executors to manage, using, 788, 801–806 group, 227, 424–429 main, 226–227, 230, 232, 233 messaging, 225, 242–247 pool, 802–804 possible states of, 224 priorities, 224–225, 236–238, 422 resuming, 249–253, 426 stopping, 249, 251–252 suspending, 226, 227, 228, 249–253, 426 and Swing, event dispatching, 867–868, 871, 873 synchronization See Synchronization ThreadGroup class, 424–429 methods, table of, 425–426 ThreadLocal class, 429 ThreadPoolExecutor class, 788, 802 throw, 205, 213–214 Throwable class, 206, 209, 219, 221, 431 methods defined by, table of, 219 obtaining object of, 213–214 throws, 205, 214–215, 217 Thumb, 716 Time See Date class timedJoin( ), 807 timedWait( ), 807 Timer class, 522–524 methods, table of, 523 TimerTask class, 522–524 methods, table of, 522 Timestamps, 641 TimeUnit enumeration, 788, 795, 805, 806–807 TimeZone class, 513–514 methods defined by, table of, 514 toArray( ), 441, 442, 450–451 toBinaryString( ), 394, 396, 397 toCharArray( ), 366 toDays( ), 807 toDegrees( ), 421 toHexString( ), 388, 389, 394, 396, 397 toHours( ), 807 Tokens, 503, 541, 590 toLowerCase( ), 375–376, 400, 401 Tomcat, 908–909 toMicros( ), 807 toMillis( ), 807 toMinutes( ), 807 toNanos( ), 807 toOctalString( ), 394, 396, 397 TooManyListenersException, 850 toRadians( ), 421 toSeconds( ), 807 toString( ), 181, 182, 209, 219, 220, 266, 272, 278, 292, 364–365, 375, 380, 388, 389, 391, 392, 394, 396, 397, 403, 413, 417, 424, 426, 430, 432, 433, 450, 483, 489, 495, 506, 507, 508, 525, 527, 528, 574, 575, 587, 602, 639, 834, 901 totalMemory( ), 405–406 toUpperCase( ), 375–376, 400 transient modifier, 299, 851 translatePoint( ), 646 Transmission Control Protocol (TCP), 601 definition of, 599 and stream-based I/O, 601 See also TCP/IP TreeExpansionEvent class, 901 TreeExpansionListener interface, 901 TreeMap class, 468, 470–471, 472, 502 TreeModel, 901 TreeModelEvent class, 901 TreeModelListener interface, 901 TreeNode interface, 901 TreePath class, 901 Trees, Swing, 900–903 TreeSelectionEvent class, 901 TreeSelectionListener interface, 901 TreeSelectionModel, 901 TreeSet class, 448, 454, 455–456, 472, 502 trim( ), 373–374 trimToSize( ), 384, 450, 489 true, 32, 39, 40, 71 TRUE, 402 True and false in Java, 40, 71 Truncation, 46 try block(s), 205, 207–213, 216 nested, 211–213 tryLock( ), 789, 808, 809 Two’s complement, 62–63 www.elsolucionario.net 1022 www.elsolucionario.net TYPE, 387, 391, 398, 402, 403 Type argument(s), 318, 320, 324 and bounded types, 325–327 and class hierarchies, 342–343 Type conversion automatic, 33, 45, 126–127 narrowing, 45 widening, 45 Type interface, 436 Type parameter(s) and bounded types, 324–326 cannot create an instance of a, 354 and class hierarchies, 343–345 and erasure, 349–351, 354 and primitive types, 320 and static members, 354–355 and type safety, 320 used with a class, 317, 322, 324 used with a method, 318, 335, 336 Type safety and arrays, 356 and collections, 475, 478 and generic methods, 336 and generics, 315, 316, 319, 320–322, 439, 475, 484, 485, 501 and raw types, 339–342 and wildcard arguments, 327–329, 331 Type-safe view, 478 Type(s) bounded, 324, 327 casting, 46–47, 48 checking, 10, 11, 33 data See Data type(s) parameterized, 316, 317 promotion, 35, 47–48 wrappers, 264–266, 272, 320, 386–403 TypeNotPresentException, 218 U UDP protocol, 599, 600, 613 UI delegate, 861, 862 ulp( ), 419, 420 UnavailableException class, 912, 915 Unboxing, 266 Unchecked warnings and raw types, 341–342 UnicastRemoteObject, 837 Unicode, 37, 38, 40, 286, 360, 361–362, 366, 400, 578 code points, table of methods providing support for, 401–402 support for 32-bit, 401–402 Uniform Resource Identifier (URI), 612 Uniform Resource Locator (URL) See URL (Uniform Resource Locator) UNIX, 4, 599 UnknownHostException, 601, 602 unlock( ), 789, 808, 809 unmodifiable collections methods, 478, 479 Unreachable code, 210–211 unread( ), 572, 585 UnsupportedOperationException, 218, 440, 441, 442, 459, 464, 478 update( ), 518, 519, 623, 625, 626, 676 overriding, 623 URI class, 612 URL (Uniform Resource Locator), 605–606, 612, 907 specification format, 606 URL class, 605–607, 610, 633 URLConnection class, 607–610 useDelimiter( ), 547 User Datagram Protocol (UDP), 599, 600, 613 useRadix( ), 549 UUID class, 553 V value (annotation member name), 281, 282 VALUE (PARAM), 630 valueBound( ), 919 valueChanged( ), 896, 901 valueOf( ), 258–259, 364, 374–375, 380, 381, 388, 389, 391, 392, 394, 396, 403, 433 values( ), 258–259, 465 valueUnbound( ), 919 van Hoff, Arthur, Varargs, 14, 151–156 and ambiguity, 155–156 and formatted I/O, 525 methods, overloading, 154–155 and Java’s printf( ), 151 parameter, 153–154, 458 Variable(s), 41–45 declaration, 25, 27, 41–42 definition of, 24, 42 dynamic initialization of, 42 enumeration, 256 final, 143 instance See Instance variables interface, 193, 200–202 object reference See Object reference variables scope and lifetime of, 42–45 1023 www.elsolucionario.net Index www.elsolucionario.net Java: The Complete Reference Vector class, 438, 448, 449, 463, 487–490 methods, table of, 489 VetoableChangeListener interface, 851 void, 23, 112 Void class, 403 volatile modifier, 238, 299 VSPACE, 630 W wait( ), 181, 243, 245–246, 252, 413, 808 waitFor( ), 403, 407 Warth, Chris, wc( ), 589–592 WeakHashMap class, 468 Web browser executing applet in, 298, 299, 617, 621, 628–629, 667 using status window of, 628 Web server and servlets, 907, 908 while loop, 84–86 Whitespace, 30, 78 from string, removing, 373–374 whitespaceChars( ), 591 Whois, 600, 604–605 WIDTH, 629 Wildcard arguments, 327–334 bounded, 329–334 used in creating an array, 356 used with instanceof, 347 Window displaying information within, 676 frame See Frame window(s) fundamentals, 666–667 status, using, 628 Window class, 649, 665, 667, 742 windowActivated( ), 653 windowClosed( ), 653 windowClosing( ), 653, 668, 669 WindowConstants interface, 866 windowDeactivated( ), 653 windowDeiconified( ), 653 WindowEvent class, 640, 642, 648–649 WindowFocusListener interface, 650, 652 windowGainedFocus( ), 652 windowIconified( ), 653 WindowListener interface, 650, 653, 668 windowLostFocus( ), 652 windowOpened( ), 653 wordChars( ), 591 World Wide Web (WWW), 6, 7, 605 wrap( ), 817 Wrappers, primitive type, 264–266, 272, 320, 386–403 write( ), 286, 292, 295, 563, 580–581, 594, 818, 822, 823 writeBoolean( ), 576, 594 writeDouble( ), 576, 594 Writer class, 286, 288, 562, 579 methods defined by, table of, 580–581 writeExternal( ), 593 writeInt( ), 576 writeObject( ), 593 writeTo( ), 569 X XOR (exclusive OR) operator (^) bitwise, 62, 63, 64–65 Boolean, 71, 72 Y Yellin, Frank, Z Zero crossing, 63 ZIP file format, 554 www.elsolucionario.net 1024 ... version of Java With the release of Java SE 6, Sun once again decided to change the name of the Java platform First, notice that the “2” has been dropped Thus, the platform now has the name Java SE,... programming for the Internet The Java Virtual Machine (JVM) and bytecode changed the way we think about security and portability The applet (and then the servlet) made the Web come alive The Java Community... portability Java? ??s Magic: The Bytecode The key that allows Java to solve both the security and the portability problems just described is that the output of a Java compiler is not executable code Rather,

Ngày đăng: 16/10/2021, 15:36

TỪ KHÓA LIÊN QUAN

w