+ All Categories
Home > Documents > LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281...

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281...

Date post: 01-Jun-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
22
INDEX Symbols (shortcut operator), 38, 39 $ character, 31 % (remainder operator), 35, 60 %=, 40 %b, 84 %c, 84 %d, 84 %e, 84 %f, 84 %s, 84 & symbol, 1159 & (unconditional AND operator), 70, 89 && (and), 69, 89 truth table for, 69 * (multiplication) operator, 35 * (multiplication operator), 60 * (multiplication), in SQL, 1104 *=, 40 ^ (exclusive or), 69 truth table for, 69 (unconditional OR operator), 70, 89 (or), 69, 89 truth table for, 69 + (addition operator), 35, 60 + (addition), SQL, 1104 + (concatenation operator), 30, 44 + symbol, 1159 ++ (shortcut operator), 38, 39 ++ (var operator), 39 ++x (preincrement operator), 39 +=, 40 += (shortcut operator), 38, 45 < (less than), 68, 89 <= (less than or equal to), 68, 89 =, 40 40 = (assignment operator), 40, 1159 != (not equal to), 68, 89 == (comparison operator), 68, 264 equals method vs., 323 > (greater than), 68, 89 >= (greater than or equal to), 68, 89 / (division operator), 35, 60 in SQL, 1104 ! (not), 69, 89 truth table for, 69 - (subtraction operator), 35, 60 in SQL, 1104 : symbol, 84 ? symbol, 84, 1159 A abs method, Math class, 144 Absolute file name, 284 AbstractBorder class, 952 Abstract classes, 212, 342 abstract methods, 342 compared to regular classes, 344 defined, 342–346 defining constructors of, 344 interfaces vs., 350–352 superclass of, 344 as types, 344 without abstract method, 344 >, 7 Abstract methods, 342, 344 in abstract classes, 344 defined, 344 abstract (modifier), 21 Abstract Windows Toolkit (AWT): defined, 401 Swing vs., 401 AbstractAction, 979 AbstractButton, 492, 971, 1015 AbstractCollection class, 390 Collection interface, 715–716 Abstraction, 372, 377 AbstractList class, List interface, 724 AbstractListModel, 1029 AbstractMap class, 733–734 AbstractSequentialList class, 724 AbstractSet class, 390 AbstractSpinnerModel, 1018–1019 AbstractTableModel, 1051 Access, 1176 batch updates, 1131 BLOB/CLOB, 1150 tutorial, 1099 Access order, 734 Accessibility modifiers, 320–321 Accessor, 230, 249 Accessor (get) methods, and JavaBeans, 898 AccountWithoutSync.java, 787–789 AccountWithSyncUsingLock.java, 791–792 acme.jar, 1196 action attribute, <form> tag, 1172 Action events: handling, 472–473 TestActionEvent.java, 473 Action interface, 978–982 UML class diagram, 979 actionCommand property, 1015 ActionEvent, 466, 467–468 addActionListener, 468 ActionInterfaceDemo.java, 980–982 ActionListener interface, 342, 465, 467, 468, 1011 actionPerformed method, 363, 468, 901 actionPerformed handler, 971 actionPerformed method, 363, 468, 901 ActionListener interface, 363 Actions, JSP, 1211 Activation, 390 Actual parameter, 130 Ada, 8–9 add method, Container class, 405 addActionListener method, 468, 485 addActionListener(listener), 363 addAll method, 715 Collection interface, 715–716 addBatch method, Statement interface, 1131 Addition ( + ) operator, 35 AdditionTutor.java, 72 addLayoutComponent method, 938–939 addMatrix method, GenericMatrix class, 706 Address book (case study), 623–629 address components, 624 AddressBook.java, 625–629 address.dat, 624 fixed-length record, 624 FixedLengthStringIO.java, 624–625 AddressBook.java, 625–629 address.dat, 624 Address.java, 379–380 addStudent method, 244–245 addXListener, 468 AdjustmentEvent, 466, 467, 516 AdjustmentListener interface, 467 adjustmentValueChanged method, AdjustmentListener interface, 516 Advanced data structures, 28 Advanced Java database programming, 1125–1156 batch processing, 1130–1135 RowSet interface, 1145–1150 scrollable and updateable result set, 1135–1145 universal SQL client, 1126–1130 Advanced math learning tool (example), 97–98 Aggregated class, 374 Aggregating object, 374 Aggregation, 374 defined, 374 representation of, 374 Algorithm efficiency, 743–768 average-case analysis, 745 best-case analysis, 744–745 Big O notation, 744–745 binary search, analyzing, 745 bubble sort algorithm, 747–748 common growth functions: change of growth rates, 746 comparing, 746–747 constant time, 745 estimating, 744–747 execution time, 744 growth rate, 744 exponential algorithm, 746 external sort, 759–765 heap sort, 755–759 insertion sort, analyzing, 746 large input size, 745 merge sort, 749–754 multiplicative constants, ignoring, 747 non-dominating terms, ignoring, 747 quadratic algorithm, 748 quick sort, 752–755 selection sort, analyzing, 745–746 Towers of Hanoi problem, 746 worst-case analysis, 745 Algorithms, 2, 28 align attribute: <applet> tag, HTML, 540 <img> tag, 1195 alt attribute: <applet> tag, HTML, 540 <img> tag, 1195 Ambiguous invocation, 139 Anchor component, 937 Anchor edge, 937 Animation: using the Timer class, 482–485 AnimationDemo.java, 483 ClockAnimation.java, 484 Anonymous inner class, 471–472 anonymous adapter advantages, 472 defined, 471 SimpleEventDemoAnonymousInnerClass.java, 472 Anonymous objects, 218 Apache, 1159 1281
Transcript
Page 1: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

INDEXSymbols

(shortcut operator), 38, 39$ character, 31% (remainder operator), 35, 60%=, 40%b, 84%c, 84%d, 84%e, 84%f, 84%s, 84& symbol, 1159& (unconditional AND operator), 70, 89&& (and), 69, 89

truth table for, 69* (multiplication) operator, 35* (multiplication operator), 60* (multiplication), in SQL, 1104*=, 40^ (exclusive or), 69

truth table for, 69(unconditional OR operator), 70, 89(or), 69, 89truth table for, 69

+ (addition operator), 35, 60+ (addition), SQL, 1104+ (concatenation operator), 30, 44+ symbol, 1159++ (shortcut operator), 38, 39++ (var operator), 39++x (preincrement operator), 39+=, 40+= (shortcut operator), 38, 45< (less than), 68, 89<= (less than or equal to), 68, 89

=, 4040

= (assignment operator), 40, 1159!= (not equal to), 68, 89== (comparison operator), 68, 264

equals method vs., 323> (greater than), 68, 89>= (greater than or equal to), 68, 89/ (division operator), 35, 60

in SQL, 1104! (not), 69, 89

truth table for, 69- (subtraction operator), 35, 60

in SQL, 1104: symbol, 84? symbol, 84, 1159

A

abs method, Math class, 144Absolute file name, 284AbstractBorder class, 952Abstract classes, 212, 342

abstract methods, 342compared to regular classes, 344defined, 342–346defining constructors of, 344interfaces vs., 350–352superclass of, 344as types, 344without abstract method, 344

>�,�

7�

��

Abstract methods, 342, 344in abstract classes, 344defined, 344

abstract (modifier), 21Abstract Windows Toolkit (AWT):

defined, 401Swing vs., 401

AbstractAction, 979AbstractButton, 492, 971, 1015AbstractCollection class, 390

Collection interface, 715–716Abstraction, 372, 377AbstractList class, List interface, 724AbstractListModel, 1029AbstractMap class, 733–734AbstractSequentialList class, 724AbstractSet class, 390AbstractSpinnerModel, 1018–1019AbstractTableModel, 1051Access, 1176

batch updates, 1131BLOB/CLOB, 1150tutorial, 1099

Access order, 734Accessibility modifiers, 320–321Accessor, 230, 249Accessor (get) methods, and JavaBeans, 898AccountWithoutSync.java, 787–789AccountWithSyncUsingLock.java, 791–792acme.jar, 1196action attribute, <form> tag, 1172Action events:

handling, 472–473TestActionEvent.java, 473

Action interface, 978–982UML class diagram, 979

actionCommand property, 1015ActionEvent, 466, 467–468

addActionListener, 468ActionInterfaceDemo.java, 980–982ActionListener interface, 342, 465, 467,

468, 1011actionPerformed method, 363, 468, 901

actionPerformed handler, 971actionPerformed method, 363, 468, 901

ActionListener interface, 363Actions, JSP, 1211Activation, 390Actual parameter, 130Ada, 8–9add method, Container class, 405addActionListener method, 468, 485addActionListener(listener), 363addAll method, 715

Collection interface, 715–716addBatch method, Statement interface, 1131Addition ( + ) operator, 35AdditionTutor.java, 72addLayoutComponent method, 938–939addMatrix method, GenericMatrix class, 706Address book (case study), 623–629

address components, 624AddressBook.java, 625–629address.dat, 624fixed-length record, 624FixedLengthStringIO.java, 624–625

AddressBook.java, 625–629

address.dat, 624Address.java, 379–380addStudent method, 244–245addXListener, 468AdjustmentEvent, 466, 467, 516AdjustmentListener interface, 467adjustmentValueChanged method,

AdjustmentListener interface, 516Advanced data structures, 28Advanced Java database programming, 1125–1156

batch processing, 1130–1135RowSet interface, 1145–1150scrollable and updateable result set, 1135–1145universal SQL client, 1126–1130

Advanced math learning tool (example), 97–98Aggregated class, 374Aggregating object, 374Aggregation, 374

defined, 374representation of, 374

Algorithm efficiency, 743–768average-case analysis, 745best-case analysis, 744–745Big O notation, 744–745binary search, analyzing, 745bubble sort algorithm, 747–748common growth functions:

change of growth rates, 746comparing, 746–747

constant time, 745estimating, 744–747

execution time, 744growth rate, 744

exponential algorithm, 746external sort, 759–765heap sort, 755–759insertion sort, analyzing, 746large input size, 745merge sort, 749–754multiplicative constants, ignoring, 747non-dominating terms, ignoring, 747quadratic algorithm, 748quick sort, 752–755selection sort, analyzing, 745–746Towers of Hanoi problem, 746worst-case analysis, 745

Algorithms, 2, 28align attribute:

<applet> tag, HTML, 540<img> tag, 1195

alt attribute:<applet> tag, HTML, 540<img> tag, 1195

Ambiguous invocation, 139Anchor component, 937Anchor edge, 937Animation:

using the Timer class, 482–485AnimationDemo.java, 483ClockAnimation.java, 484

Anonymous inner class, 471–472anonymous adapter advantages, 472defined, 471SimpleEventDemoAnonymousInnerClass.java,

472Anonymous objects, 218Apache, 1159

1281

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281

Page 2: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1282 Index

Applet class, 536–538, 564–565, 1157destroy method, 538, 565flow of control of, 537getParameter method, 565init method, 537no-arg constructor, 537param attribute, 565start method, 537stop method, 537subclass of, 536

Applet clients, 826–829, 834, 856AppletClient.java, 828–829CountServer.java, 827–828

Applet Viewer, 563<applet> tag, HTML, 539–544, 546, 564–566

align attribute, 540alt attribute, 540archive attribute, 540codebase attribute, 540hspace attribute, 540syntax for, 537, 539syntax of, 539vspace attribute, 540

AppletClient.java, 828–829Applets, 14, 17, 535–574

adding a component to, 538audio, playing, 559–560

DisplayImagePlayAudio.java, 559–560bouncing ball application, 554–557

UML class diagram, 555bytecode, 565content pane delegation feature, JDK 1.5, 405,

538defined, 535demos, 544enabling to run as applications, 544–546LoanApplet.java, 542–543

with main method, 545–546public modifier, 543

and main method, 536, 545–546, 549multimedia animations, 560–562passing strings to, 546–550security restrictions, 544–545TicTacToe game, 550–554trusted, 545URL class, 557–560viewing:

using the applet viewer utility, 540–541from a Web browser, 541–542

Appletviewer, 540Application program interface (API), 16Application programs, 10Application scope, 1232application value, scope attribute, 1220application variable, JSP, 1214Approximations, 36archive attribute, <applet> tag, HTML, 540Archiving/archive files, 562–564Arcs:

DrawArcs.java, 436–437drawing, 436–438negative degrees, 437

Arguments, 130, 135–139Arithmetic expressions, 37–38, 89Arithmetic operators, SQL, 1104ArithmeticException, 582Arithmetic/logic unit, CPU, 5Array initializers, 172Array limitation, 660–661Array lists, 663–668

MyArrayList.java, 664–667TestList.java, 667–668

Array of reference variables, 237

Array variables:declaring, 170

syntax for, 170arraycopy method, 178, 356ArrayIndexOutOfBoundsException, 175,

578, 586ArrayList class, 315–318, 375–376, 694–695,

724–726trimToSize() method, 724–725UML class diagram, 695, 724

Arrays, 169–209, 237, 660, 661array variables vs., 170basics of, 170–177conversions between strings and, 268–269copying, 177–178creating, 170–171default values, 171defined, 170indexed variables, 171initializers, 172length, 171multidimensional, 199–201as objects, 217passing to methods, 179–181processing, 172–173

foreach loops, 174ragged, 194–195returning from a method, 181–185searching, 185–188

binary search approach, 186–188linear search approach, 186

serializing, 620size, 171sorting, 188–191

insertion sort, 190–191selection sort, 188–190

testing (example), 174–175two-dimensional, 192–199

Arrays class, 191–192Arrays of objects, 237–239

sorting, 360–361Arrays.asList(T... a) method, 728Arrays.sort method, 362Arrow keys, 7Ascent, 440ASCII (American Standard Code for Information

Interchange), 42ASCII character set, 612ASCII code, 607, 612

asList method, 726Assembler, 8Assembly languages, 8Assembly programs, 8AssertionError class, 594

Error class, 581Assertions, 593–595

declaring, 593–594defined, 593example of using, 594–595reaffirming, 595running programs with, 594using, 595

Assigning grades (example), 176–177Assigning values, 30, 33AssigningGrade.Java, 176–177Assignment expressions, 32Assignment operator ( = ) 32, 40Assignment statements, 32–33Association, 373–374

dependency vs., 376illustration of, 373implementation, 374multiplicity, 373

Associativity, 86–87Attributes, 1095Attributes, HTML, 539autoFlush attribute, page directive, 1216Automatic scrolling, 943Average-case analysis, 745await() method, 793AWTError subclass, Error class, 581AWTException, 581

BBackslash (/), 280

escape sequences and, 43in file names, 285

Backward compatibility, and raw type, 699BallControl.java, 556–557Ball.java, 555–556Base, 11Base case, 640Base class, 302, 331BASIC, 8–9Basic computer skills, 2Batch processing, 1130–1135

CopyFileToTable.java, 1131–1135Bean components, See JavaBeans, componentsBeans, See JavaBeansBest-case analysis, 744–745Best-case input, 744–745between-and operator, 1102–1103BevelBorder class, 952–953Big O notation, 744–745BigDecimal class, 359BigInteger class, 359Binary codes, 7Binary digits, 5Binary files:

advantage of, 606defined, 606

Binary I/O, 605–634characters and strings in, 612–614classes, 606and conversions, 606efficiency of, 606TestFileStream.java, 610text I/O vs, 606–608

Binary numbers, 11conversion between decimal numbers

and, 11–12Binary operator, 36, 89Binary search algorithm, 745Binary search, analyzing, 745Binary search approach, 186–188Binary search trees, 678

inserting an element into, 678–679Binary trees, 660, 677–683

binary search trees, 678inserting an element into, 678–679

BinaryTree class, 680–682BinaryTree.java, 680–682complete, 683leaf, 678left (right) child of a node, 678left subtree, 677–678representing, 678right subtree, 677–678root, 677TestBinaryTree.java, 682–683tree traversal, 679–680

binarySearch method, 192and lists, 727

BinarySearch.java, 187–188, 745BinaryTree class, 680–682

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1282

Page 3: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1283

BinaryTree.java, 680–682bind method, 1246BirthDate class, 232–233Bits, 5, 11Bitwise operations, 71Blind extensions, classes, 306BLOB (Binary Large OBject), 1150Block styles, 56–57Blocked state, threads, 803Blocking queues, 799–801

ConsumerProducerUsingBlockingQueue.java,800–801

Blocks:Java, 21nested, 141–142

BlueJ, 17<body> tag, HTML, 539boolean accessor, 230Boolean class, 270, 356–357boolean data type and operations, 68–69Boolean literals, 71Boolean operators, 69, 89

SQL, 1102Boolean types, 28boolean value, testing, 77Boolean variable, 68boolean variable, assigning, 77boolean wasNull() method, 1136Border interface, 952BorderDemo.java, 956–959BorderLayout manager, 410–412

defined, 410hgap property, 412ShowBorderLayout.java, 410–411UML class diagram, 410vgap property, 412

Borders, sharing, 418Borland Interbase, 1099Borrower.java, 381–382BorrowLoan.java, 382Bottom-up implementation, 149–151BounceBallApp.java, 557Bouncing ball application, 554–557

BallControl.java, 556–557Ball.java, 555–556BounceBallApp.java, 557UML class diagram, 555

Bounded generic type, 699Bounded wildcards, 701BoundedTypeDemo.java, 699Boxing, 362BoxLayout manager, 930–933

fillers, 931ShowBoxLayout.java, 932–933

Breadth-first traversal, 680break (keyword), 83, 89, 113–114

omitting, 83break statement, 81, 101, 115–116Browsers, See Web browsersBrowseTable.jsp, 1236–1237Bubble sort:

defined, 747illustration, 747time, 748–749

Bubble sort algorithm, 747–748improved, 748

BubbleSort.java, 748buffer attribute, page directive, 1216BufferedImage class, 1199BufferedInputStream, 614–615, 630BufferedOutputStream, 614–615, 630Bugs, 58–59Built-in monitor, Java, 796–797

Bus, 4ButtonDemo.java, 496–497ButtonGroup, 501ButtonModel, 1015Buttons, 492–498

AbstractButton, 492alignments, 494ButtonDemo.java, 496–497defined, 492horizontal alignment, 494horizontal text position, 495icons, 492–494JButton class, 493pressed icons, 492–494rollover icons, 492–494TestButtonIcons.java, 493–494types of, 492using (example), 495–498vertical alignment, 494vertical text position, 495

byte, 32, 34, 89Byte class, 270, 356Bytecode, 9, 19, 565Bytecode verifier, 20Bytes, 5

address, 5byteValue() method, 357

CC, 8–9C#, 8C++, 8–9Cable modem, 7, 816Cached pools, 786CacheRowSet, 1145Calculator.java, 279Calendar class, 148, 345–346, 375–376, 864

add(field, amount) method, 347constructing calendars, 346getActualMaximum(field) method, 347get(int field) method, 347gettime() method, 347set(int field, value) method, 347UML class diagram, 345

CalendarApp.java, 874–875CalendarPanel.java, 871–873Call stacks, 133CallBackImpl.java, 1261CallBack.java, 1257Callbacks, defined, 1255–1256Called method, 131, 158Calling object, 217CancelListenerClass, 365cancelRowUpdates() method, 1136Candidate key, 1096–1097capacity() method, StringBuffer class, 275CardLayout manager, 921–924

defined, 921methods, 921ShowCardLayout.java, 922–924UML class diagram, 922

Case sensitivity, of Java, 21, 31Casting, 40–41, 60

between char and numeric types, 43–44demonstrating, 314–315loss of precision, 41and object member access operator (.), 315syntax, 40

Casting objects:casting analogy, 314downcasting, 314explicit casting, 313

implicit casting, 313and instanceof Operator, 313–315upcasting, 313–314

catch block, 580, 585finally clause and, 589

catch (keyword), 580Catching an exception, 582CD drives (CD-R, CD-RW, and DVD), 6CD-ROMs, 239CD-Rs, 6CD-RWs, 6CDs, 4Cell class, 551, 554, 1257, 1265Central processing unit (CPU), 4–5, 239

arithmetic/logic unit, 5components of, 4–5control unit, 4–5speed of, 5

CGI programs, 1158–1160Chained exceptions, 591–593ChainedExceptionDemo.java, 591–593char, 32, 41, 89

increment/decrement, 42operand, 145

char literal, 41Character class, 270–273, 275, 292, 356–357, 357

constructor/methods, 270–273Character data type, 41–42Character encoding, 42, 606, 888–889, 1176, 1227

EncodingDemo.java, 889and internationalization, 888–889

Character literal, 41Characters, 59

comparing, 68charAt(index) method, 265charAt(int) method, StringBuffer class, 275charValue method, 267Check box menu items, creating, 969Check boxes, 400, 498–501

CheckBoxDemo.java, 499–500toggle button, 498

checkbox input type, 1171checked attribute, <input> tag, 1172Checked exceptions, 582CheckPalindrome.java, 270Child class, 302, 331Choice lists, See Combo boxesCircle class, 214, 215–218, 224, 227, 232, 236,

238, 252and GeometricObject class, 302methods, 305

Circle1.java, 219–220Circle2.java, 225Circle3.java, 230–231circleArray, 237CircleControl (model example, 1008–1009

CircleController.java, 1012–1013CircleModel.java, 1009–1011properties of, 1008–1009UML class diagram, 1009

Circle.java, 304–305, 344CircleModel.java, 1009–1011CircleView, 1008, 1009, 1011

CircleView.java, 1011–1012UML class diagram, 1011

CircleWithException.java, 587–589Clarity, in class design, 387Class abstraction, 239Class block, 21Class contract, 239Class design guidelines, 387–390

clarity, 388cohesion, 387

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1283

Page 4: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1284 Index

Class design guidelines (Continued)completeness, 389consistency, 387–388encapsulation, 388inheritance vs. aggregation, 389–390instance vs. static, 389

common design error, 389interfaces vs. abstract classes, 350–352, 390naming consistency, 387–388naming conventions, 387no-arg constructor, 388private constructor, 388protected constructor, 388separating responsibilities, 387

Class diagram, 215Class directory path, 156Class encapsulation, 239Class files, archiving, 156class keyword, 25, 28Class loader, 20Class names, 17Class operations, coherent purpose, 387Class role, 390ClassCastException, 314, 349, 697Classes, 216

attributes/methods, describing, 378declaring, 218–220identifying, 377and inheritance, 377Java, 21, 214from the Java library, 221–222main class, 214naming, 55, 56and objects, 214reuse of, 330, 372, 378, 407variables, 235

classes12.jar, 1107–1108, 1177ClassName.staticVariable, 227, 236ClassNotFoundException, 581, 596, 618, 620,

1251classpath, 155clear method, 667, 716, 733, 1029clear() method, Collection interface, 716clear method, Map interface, 733Client, 230, 375Client program, 147, 231, 777, 817–819, 822, 824,

827, 1244RMI, 1245, 1252

Client, RMI, 1244Client sockets, 817Client.java, 820–822Client/server computing, 816–822

applet clients, 826–829, 834, 856client sockets, 817example of, 818–822server sockets, 816–817socket-based communication, 816sockets, 816, 818

data transmission through, 818CLOB (Character Large OBject), 1150Clock speed, 5Clock with audio (case study), 782–785

ClockWithAudio.java, 782–784ClockWithAudioOnSeparateThread.java,

784–785ClockAnimation.java, 484clone method, 324–325, 355

CloneNotSupportedException, 322Object class, 324–325

Cloneable interface, 325, 354–356, 874implementing, 354

cloneCalendar, 874CloneNotSupportedException, 355, 581COBOL, 8–9, 214

Code Warrior (Metrowerks), 17codebase attribute, <applet> tag, HTML, 540Coding, 28, 372, 378Cohesion, in class design, 388Collection, defined, 714Collection interface, 390

AbstractCollection class, 715–716addAll method, 715–716basic operations provided by, 715clear() method, 716contains method, 716containsAll method, 716isEmpty method, 716java.lang.UnsupportedOperationException,

716query operations, 716remove method, 716removeAll method, 716retainAll method, 716set operations, 716size method, 715toArray() method, 716UML class diagram, 715

Collection objects, 660Collections:

defined, 714singleton, 737–738static methods for, 726–729unmodifiable, 737–738

Collections class, 726–727, 737–738, 746UML class diagram, 726–728

Collections class class, 737–738Color class, 403, 412–413Color constants, 412–413ColorDialog.java, 989–991cols attribute, <textarea> … </textarea> tags,

1172Column alias, 1103Column model, JTable, 1046Combo boxes, 509–512

cell rendering, 1036–1037ComboBoxDemo.java, 510–512defined, 1035JComboBox, 509–511

ComboBoxCellRendererDemo.java, 1037–1038ComboBoxDemo.java, 510–512ComboBoxModel interface, 1036

UML class diagram, 1036Command-line arguments, 277–279

passing strings to the main method, 277–279processing, 278–279

Command-line debugger (jdb), JDK, 58Comments, 20–21, 55

defined, 20JSP, 1212

commit() method, 1110Common Gateway Interface (CGI), 1158Communication devices, 4, 7com.mysql.jdbc.Driver, 1108Comparable interface, 348, 360, 360–361, 383,

387, 390, 392, 395, 735declaring classes to implement, 348

ComparableRectangle.java, 348–349Comparator interface, 721–723, 735

compare method, 722GeometricComparator.java, 721–721TestTreeSetWithComparator.java, 722–723

compare method, 722compareTo method, 265, 292, 348, 355, 694Comparison operators, 68

SQL, 1102Compilation errors, 57, 60Compiler, 9, 34, 312

Java, 19

Compiling vs. interpreting, 9Complete binary trees, 683Component class, 413, 446, 466

and ImageObserver interface, 451setFont method, 413

Component classes, 402Component events, 484ComponentAdapter, 476ComponentEvent, 466ComponentListener interface, 467

ComponentAdapter, 476Components, See also JavaBeans, components

naming convention for, 492Composition, 320, 374, 675

and object-oriented design, 374CompoundBorder class, 952–953ComputeArea.java, 28, 29–30, 68ComputeChange.java, 49–50computeFactorial method, 1219ComputeFactorial.java, 637–638ComputeFactorial.jsp, 1218–1219ComputeFibonacci.java, 639–640ComputeLoan., 1214–1215ComputeLoan1.jsp, 1216–1217ComputeLoan2.jsp, 1223–1224ComputeLoanAlternative.java, 54–55ComputeLoan.java, 47–48ComputeLoan.jsp, 1215Computer programming, defined, 4Computer programs, 7–8Computers:

clock speed, 5components of, 4defined, 4

ComputeTax.java, 198–199ComputeTaxWithMethod.java, 140–141, 198ComputeTaxWithSelectionStatement.java, 79–80,

198Computing loan payments, 46–47concat method, 292Concatenating strings, 30, 44–45, 226Concatenation operator ( + ), 30Concrete classes, 715CONCUR_READ_ONLY constant, 1135CONCUR_UPDATABLE constant, 1135ConcurrentModificationException, 805Condition interface, 793Conditional AND operator, 70, 89Conditional expressions, 83–84Conditional operator, 84Conditional OR operator, 70, 89config variable, JSP, 1214Confirmation dialog:

controlling a loop with, 98–99defined, 982

Confirmation dialogs, 983–985defined, 983

Conflict interfaces, 342Connected RowSet object, 1145Connection interface, 1110, 1113, 1116, 1120Consistency, in class design, 387–388Console, getting input from, 52–53Console output, 17

formatting, 84–86Constant time, 745Constants, 33–34

benefits of, 34naming, 34, 55static, 224–228

Constructor chaining, 307–308Constructors, 214, 331

default constructor, 216name of, 216new operator, 216

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1284

Page 5: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1285

no-arg (no-argument) constructors, 216overloading, 216and return type, 216and void keyword, 216

ConsumerProducer.java, 797–799ConsumerProducerUsingBlockingQueue.java,

800–801Container class, 403, 405, 415, 466, 544

add method, 918, 939Container classes, 403Container objects, 660ContainerAdapter, 476ContainerEvent, 466–467, 918ContainerListener interface, 467

ContainerAdapter, 476Containers, 400–406

alignmentX (alignmentY) property, 920defined, 290maximumSize property, 920minimumSize property, 920preferredSize property, 920size of a component in, 920Swing container structures, 918–920

contains method, Collection interface, 716containsAll method, Collection interface,

716containsKey method, Map interface, 733containsValue method, Map interface, 733Content pane, defined, 405Content pane delegation, 405Contention, 779contentPane property:

JApplet, 919JFrame, 989

contentType attribute, page directive, 1216Context menu, 975, 1001Contiguous selection, 512, 1026, 1078continue (keyword), 113–114Contract, class, 239Control statements, 108Control unit, CPU, 4–5Control variable, 103Controller, 1008Convenience adapters, 476, 485Convenience classes, 390, 661Converting operands, 40–41Cookie class, 1189Cookies, 1167, 1180, 1201, 1213

session tracking using, 1185–1190copy() method, and lists, 726CopyFile.java, 806–807, 807–808CopyFileToTable.java, 1131–1135Copy.java, 615–616CornerPanel class, 947CountEachLetter.java, 272–273Count.java, 1220–1221

revised version, 1221–1222Count.java (revised version), 1221–1222countLetters method, 272–273CountLettersInArray.java, 182–183CountOccurrenceOfWords.java, 736–737Country codes, 862–863CountServer.java, 827–828Course class, 243–245

implementation, 244–245Course.java, 244–245CourseWithEnrollmentEvent.java, 908–910CPU, See Central processing unit (CPU)createCircleArray method, 238Critical region, 789, 792Currency format, 877, 892currentDirectory property, JFileChooser, 995CurrentTime servlet, 1169CurrentTime.java, 1169–1170

currentTimeMillis method, System class, 50–51cursorMoved(RowSetEvent), 1149cursorSetChangeed(RowSetEvent), 1149Custom dialogs, creating, 989–92Custom exception classes, creating, 342–343,

592–593Custom interfaces, creating, 342–343Custom layout managers, creating, 938–943Custom stack class, 319–320Custom table renderers and editors, 1062–1065CustomFrame class, 330CustomFrame.java, 330CustomTableCellRenderEditorDemo.java,

1064–1065

DData field encapsulation, 214, 229–232Data fields, 214, 235

hiding, 325–327Data structures, defined, 660Database, defined, 1094Database management system (DBMS), 1094Database programming, in servlets, 1180Database systems:

components of, 1094defined, 1094JDBC, 1106–1113relational, 1094–1098Structured Query Language (SQL), 1098–1106

Database table browsing (case study), 1232–1238BrowseTable.jsp, 1236–1237DBBean.java, 1233–1235DBLogin.html, 1235DBLoginInitialization.jsp, 1235–1236Table.jsp, 1236

DatabaseMetaData interface, 1116–1117, 1120databaseURL, 1108

for an Access database, 1108–1109for a MySQL database, 1108–1109for an Oracle database, 1109

Datagram programming, 851–856Datagram socket programming, 816Datagram sockets, 816

constructing, 850–856creating, 850

DatagramClient.java, 854–855, 854–856DatagramPacket class, 850–851Datagrams, defined, 850DatagramServer.java, 852–853DatagramSocket class, 851DataInputStream, 611–612, 818

using, 613DataOutputStream, 611–612, 818

using, 613Date class, 222–223, 285, 864DateFormat class, 865–875, 1228

DateFormatSymbols class, 866–875FULL constant, 865LONG constant, 865MEDIUM constant, 865SHORT constant, 865SimpleDateFormat class, 865–866UML class diagram, 865

DateFormatSymbols class, 866–875UML class diagram, 866

dateStyle method, 865DBBean.java, 1233–1235DBLogin.html, 1235DBLoginInitialization.jsp, 1235–1236Deadlocks:

avoiding, 803defined, 803resource ordering, 803, 809

Debugging, 58–59, 372, 578in integrated development environment (IDE), 58

Decimal number system, 11Decimal numbers, 11

conversion between binary numbers and, 11–12conversions between hexidecimal numbers

and, 12–13DecimalFormat Class, 877–878Declarations, JSP, 1211Declared type of the reference variable, 312Declaring an exception, 587–589Declaring variables, 30, 31–32Decrement operators, 38–39, 60Deep copy, 355Default constructor, 216Default field values, 220Default modifiers, 228DefaultButtonModel, 1015DefaultCellEditor, 1065, 1084DefaultComboBoxModel, 1036–1037DefaultListModel, 1029–1030DefaultListSelectionModel, 1026DefaultMutableTreeNode, 1069DefaultTableColumnModel, 1053DefaultTableModel, 1051DefaultTreeCellEditor, 1069DefaultTreeCellRenderer, 1069, 1084DefaultTreeModel, 1069, 1073–1074DefaultTreeSelectionModel, 1078Delegation-based model, 900Delete key, 7delete method, strBuf, 274deleteRow() method, 1136Delphi, 8–9Dependency, 375–376

association vs., 376Dependent component, 937Dependent edge, 937Deployment, 373deposit method, 789Deprecated methods, 777Depth-first traversal, 680

defined, 680, 1074dequeue(o) method, 677Derived class, 302Descent, 440Descriptive identifiers, 31Descriptive names:

full, 56variables, 29

Deserialization, 619destroy method:

Applet class, 538, 565Servlet interface, 1165

DiagonalLayout.java, 940–942dialogTitle property, JFileChooser, 994dialogType property, JFileChooser, 994Dialup, 816Dialup modem, 7Dimension class, 402, 403, 942Directives, JSP, 1211, 1215–1219Directories, packages, 154–155Directory path, 284Disconnected RowSet object, 1145Discontiguous selection, 1078disjoint method, and lists, 726, 729Disk drives, 6Disks, 4

types of, 6DisplayClock.java, 447–448DisplayFigure.java, 948–949displayGeometricObject method, 345DisplayImage.java, 452DisplayImagePlayAudio.java, 559–560

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1285

Page 6: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1286 Index

DisplayImageWithURL.java, 558–559Displaying the current time (example), 50–51DisplayMessageApp.java, 548–549DisplayMessage.html, 547DisplayMessage.java, 547–548displayObject method, 314–315DisplayTimeForm.jsp, 1226–1227DisplayTime.java, 35–36DisplayTime.jsp, 1227distinct keyword, SQL, 1104Distinct tuples, sorting, 1104Distributed Java system, 1244“Divide and conquer” strategy, 147Divider, 949Division (/) operator, 35Division by zero, and runtime errors, 57Documentation, 55–57doDelete method, 1166doGet method, 1157, 1166doLayout() method, 412, 921Domain constraints, 1096Domain Name Servers (DNS), 816Domain names, 816doOptions method, 1166doPost method, 1166doPut method, 1166dot operator (.), 217Dot pitch, 7

monitors, 7doTrace method, 1166double, 32double, 34, 89, 143–144

float vs., 37Double class, 270, 356–357

parseDouble method, 359Double precision, 34Double.parseDouble method, 46doubleValue() method, 356–357do-while loops, 100–101, 111, 118Downcasting, 314draw3DRect method, 432DrawArcs.java, 436–437drawImage method, Graphics class, 451–452drawLine method, 431drawOval method, 432drawPolygon method, 439DrawPolygon.java, 439–440drawRect method, 431–432drawRoundRect method, 431drawString method, 431

Graphics class, 428Drives, defined, 6DrJava, 17Drop-down lists, See Combo boxesDSL (digital subscriber line), 7, 816DVDs, 6Dynamic binding, 311–313

benefits of, 313defined, 312

Dynamic web contents, 17, 1158–1159, 1210

EEclipse, 18, 58, 78, 97, 133, 175, 220, 898,

1011, 1163Eclipse Open Source (IBM), 17editable property, JTree, 1084Elements, defined, 714else clause, matching with if clause, 76Email programs, 4empty() method, Stack class, 730EmptyBorder class, 952–953Encapsulation, 147, 159, 386–387, 388

class, 239Encoding, 42

Encoding scheme, 42EncodingDemo.java, 889End tag, HTML, 539End-of-line style, 56–57Enhanced for loop, 174enqueue(o) method, 677EnrollmentEvent.java, 908EnrollmentListener.java, 908entrySet() method, Map interface, 733Enumeration interface, 729equalArea method, 345, 698equals method, 192, 264, 265, 292, 322–323

Object class, 322–323equalsIgnoreCase method, String class, 265Error class, 581

examples of subclasses of, 581Error pages, using (example), 1217–1219

ComputeFactorial.jsp, 1218–1219FactorialInputError.jsp, 1219FactorialInput.html, 1218

errorPage attribute, page directive, 1216Escape sequences, for special characters, 43EtchedBorder class, 952–953Evaluation rule, 88Event classes, 900Event dispatcher thread, defined, 781Event listener interface, 900

defined, 900Event objects, 900Event pair, 900Event registration, 898

JavaBeans, 898Event set, 900

custom, creating, 906–911CourseWithEnrollmentEvent.java, 908–910EnrollmentEvent.java, 908EnrollmentListener.java, 908TestCourseWithEnrollmentEvent.java,

910–911Event-driven programming:

animation using the Timer class, 482–485defined, 464events, defined, 465getSource() instance method, EventObject

class, 465key events, 479–482listeners, 465–477mouse events, 477–479SimpleEventdemo.java, 464source component, 465source object, 465Window events, handling, 474–475

EventListener interface, 900EventObject class, 485Events, defined, 465, 900Ever-waiting threads, 796Exception class, 592

examples of subclasses of, 581Exception classes, 581Exception handlers, order of, 585Exception handling, 212, 575–603

catching an exception, 587–589CircleWithException.java, 587–588declaring exceptions, 587–589defined, 578exception handler, 584–585

order of, 585exception message, 587ExceptionDemo.java, 578finally clause, 589–590HandleExceptionDemo.java, 579–580and multiple threads, 589overview of, 578–580stack trace, 579TestCircleWithException.java, 588

TestException.java, 586–587throwing an exception, 587–589understanding, 582–589using, 584–585

ExceptionDemo.java, 578Exceptions:

chained, 591–592ChainedExceptionDemo.java, 591–592

checked, 582catching/declaring, 582

compared to events, 578custom exception classes, creating, 342–343,

592–593defined, 578, 580Exception class, 581integer overflow, 582rethrowing, 591runtime, 581unchecked, 582when to use, 590–591

executeBatch method, 1131executeQuery method, Statement interface,

1136executeUpdate method, 1130Executor interface, 785–786

UML class diagram, 785ExecutorDemo.java, 786Executors class, 786ExecutorService interface, 785–786exitMenu, 974Explicit casting, 43, 313Exponent methods, Math class, 143Exponential algorithm, 746Expressions, 32

assignment, 32Expressions, JSP, 1211Extended class, 302, 331extends (reserved word), 305External sort, 759–765

CreateLargeFile.java, 760first half segments, copying, 762initial sorted segments, creating, 761–762large binary file, creating, 760merging all segments, 762–763merging two segments, 763SortLargeFile.java, 763–765

Ffactorial method, 640

and recursion, 637–638FactorialBean.java, 1224–1225FactorialBean.jsp, 1225FactorialInputError.jsp, 1219FactorialInput.html, 1218Factorial.jsp, 1212, 1219Factorials, 638–639

ComputeFactorial.java, 637–638FahrenheitToCelsius.java, 38Fail-fast, 805Fairness policies, locks, 791Fall-through behavior, 83Fibonacci, Leonardo, 638Fibonacci numbers:

ComputeFibonacci.java, 639–640and recursion, 638–640

FigurePanel class, 432–436, 948FigurePanel.java, 434–435implementation, 432TestFigurePanel.java, 433UML class diagram, 433

FigurePanel.java, 434–435File class, 283–286, 292File copying program (case study), 615–616File path character, 418

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1286

Page 7: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1287

File pointer, 622FileInputStream, 609–611

UML class diagram, 609Filename, 285FileOutputStream, 609–611

UML class diagram, 609Files, naming conventions, 418fill method, 192

and lists, 728fill3DRect method, 432Fillers, 931fillOval method, 432fillRect method, 431fillRoundRect method, 431Filter streams, defined, 611FilterInputStream class, 611FilterOutputStream class, 611final (keyword), 321, 332Final local variable, 322final (modifier), 21, 33FinalizationDemo.java, 323–324finalize method, 322, 323–324

Object class, 322finally clause, 589–590

FinallyDemo.java, 590and I/O programming, 590

finallyDemo.java, 590FindGrade.java, 1111–1112FindGradeUsingPreparedStatement.java,

1114–1116FindSalesAmount.java, 110–111FindUserTables.java, 1117–1118Fire event, 465firstKey() method, SortedMap interface,

733–734FirstServlet.java, 1161Fixed-length record, 624FixedLengthStringIO.java, 624–625FlashingText.java, 780float, 32, 34, 89Float class, 270, 356floatable property, JToolBar, 977Floating-point literals, 37Floating-point numbers, 34, 59floatValue() method, 356–357Floppy disks, 6, 239FlowLayout class, 291FlowLayout manager, 290, 406–408, 436

components/properties for specifying horizontal/vertical gap between components, 920

FocusAdapter, 476Focused components, 482FocusEvent, 466, 467FocusListener interface, 467

FocusAdapter, 476Font class, 403, 413FontMetrics class, 403, 440–442for loop, 102–104, 118, 237

adding semicolon at end of for clause beforethe loop body, 103

control variable, 103loop-continuation-condition in, omission

of, 103–104nested, 105–106syntax for, 102

foreach loops, 174, 718Foreign key constraints, 1097

defined, 1096<form> … </form> tags, 1172Formal parameters, method header, 130Format class, 155–156Format.java, 155–156FormatString.java, 289Formatter class, 289Formatting numbers, 41

FORTRAN, 8Fractals, 646–649

defined, 646Sierpinski triangle:

creation of, 646defined, 646SierpinskiTriangle.java, 647–648

Frames, 403–406adding components to, 405creating, 403MyFrame.java, 404MyFrameWithComponents.java, 405

Framework-based programming:defined, 392using Java API, 392

frequency method, and lists, 726FULL constant, DateFormat class, 865Function keys, 7Functions, 130–131

GGarbage, defined, 222Garbage collection, 177, 222, 323–324Generic instantiation, 694Generic programming, 311–313, 350, 356, 362,

365defined, 313

Generic reference types, 694GenericMatrix class, 705–710

addMatrix method, 705–706, 706GenericMatrix.java, 706–708IntegerMatrix.java, 708multiplyMatrix method, 705–706RationalMatrix.java, 708–709TestIntegerMatrix.java, 709TestRationalMatrix.java, 709–710UML class diagram, 706

GenericMatrix.java, 706–708GenericMethodDemo.java, 698, 699Generics:

actual concrete type, 694bounded generic type, 699declaring generic classes and interfaces,

695–698formal generic type, 694generic class constructor, 697generic class parameter vs. generic method

parameter, 699generic instantiation, 694generic methods, 698–699generic type limitation, 697generic types, benefits of using, 697GenericMatrix class, 705–710GenericMethodDemo.java, 698GenericStack.java, 696–697motivations, 694–695multiple generic parameters, 698raw types:

and backward compatibility, 699–700unsafe, avoiding, 703–705

wildcards, 701–703GenericServlet class, 1166GenericServlet class, UML class diagram, 1167GenericSort.java, 360–362GenericSortNew.java, 705GenericStack.java, 696–697GeometricComparator.java, 721–722GeometricObject class, 302, 302–306,

309–310, 390abstract class, 344getArea() method, 302getDiameter() method, 302getPerimeter() method, 302toString() method, 302

toString method, 309UML class diagram, 343using, 344

GeometricObject.java, 303–304, 342–343, 344get method, 214get method, 378GET method, 1159–1160getAllFonts() method, 413getArea method, 214–220, 227getArea() method, GeometricObject class, 302getAvailableFontFamilyNames() method, 413getAvailableIDs() method, TimeZone class, 864getAvailableLocales() method, Locale class, 864getBirthDate() method, 232–233getChars method, 268getClass method, 325getColumnCount method, 1130getColumnName() method, 1130getConnection(databaseURL),

DriverManager class, 1108getContentPane() method, 405, 919getCurrencyInstance, 876, 890getCurrencyInstance method,

NumberFormat.getInstance(), 877, 890

getData method, 850getDateCreated() method, 302–303, 309getDateTimeInstance method, 865getDiameter() method, GeometricObject

class, 302getElementAt method, 1029getGraphics() method, 429getHeight() method, 442getInitParameter, ServletConfig interface,

1166getInitParameterNames, ServletConfig

interface, 1166getInputStream() method, 818getInstance, 876, 890getKeyChar() method, KeyEvent, 482getKeyCode() method, KeyEvent, 482getKeyStroke method, KeyStroke class, 970getLeadSelectionPath() method, 1078getMessage() method, 583, 586, 592getMetaData method, 1130getMonthName, 148getNumberInstance, 876, 890getNumberOfDaysInMonth, 148, 149getNumberOfObjects(), 224–225, 231getOutputStream() method, 818getParameter method, Applet class, 563, 565GetParameters.java, 1173–1174getPercentInstance, 876, 890getPercentInstance(),

NumberFormat.getInstance(), 877, 890

getPerimeter() method, GeometricObjectclass, 302

getPreferredSize() method, 436getRadius method, 224, 231GetRegistrationData.jsp, 1231getSelectedItem method, 1036getSelectionPaths() method, 1080getServletContext, ServletConfig interface,

1166getServletName, ServletConfig interface, 1166getSize method, 320, 1029getSource() instance method, EventObject

class, 465getStackTrace() method, 585–586getStartDay, 148getString method, 883getStudents() method, 244–245Getter, 230, 249getTime() method, 222

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1287

Page 8: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1288 Index

getTimeInstance method, 865getTimeZone(id) method, 864getTotalNumberOfDays, 148getTotalNumberOfDays(int year,

int month), 149getWidth() method, 442getWriter method, 1170GIF (Graphics Interchange Format), 418GifEncoder class, 1198Gigahertz (GHz), 5Glue, 931–932Gosling, James, 14, 24GradeExam.java, 197Graphical notations, 213, 373, 393Graphical user interface (GUI), 525

defined, 492Graphics, 425–462

arcs, drawing, 436–438draw3DRect method, 432drawing on panels, 430–431drawLine method, 431drawOval method, 432drawRect method, 431–432drawRoundRect method, 431drawString method, 431FigurePanel class, 432, 432–436fill3DRect method, 432fillOval method, 432fillRect method, 431fillRoundRect method, 431FontMetrics class, 440–442getGraphics() method, 429graphical coordinate systems, 426Graphics class, 403images, displaying, 451–452

DisplayImage.java, 452MessagePanel class, 442–446paintComponent Method, 429polygons, 438–440polylines, 438–440StillClock class, 447–451TestPaintComponent.java, 429–430

Graphics class, 403defined, 426–427drawString method, 428setColor method, 446setFont method, 446UML class diagram, 427

Graphics object, 427GraphicsEnvironment class, 413Greatest common divisor, finding (example),

108–109GreatestCommonDivisor.java, 108–109Greedy match, 283GregorianCalendar class, 148, 345–346, 870GridBagConstraints object, constructing, 926GridBagLayout manager, 408–410, 436, 924–928

adding a component to the container of, 926anchor, 925defined, 924display area, 924filling, 925GridBagLayout() constructor, 924growth weight, 925insets, 926location, 925padding, 926properties for specifying horizontal/vertical gap

between columns/rows, 920ShowGridBagLayout.java, 927–928ShowGridLayout.java, 409–410size, 925using, 926–927

Grouping patterns, 280–282Growth rate, algorithms, 744

GUI classes:classification of, 402as JavaBeans components, 899

GUI components, 330–331, 400–401common features of, 415–418inheriting, 330–331pluggable look-and-feel feature, 960–961TestSwingCommonFeatures.java, 416–417

GUI event dispatcher thread, 781GUI events, handling, 363–364GUI helper classes, 403GUI programming, getting started with, 400–427

HHandleASession class, 839, 841–842HandleEvent.java, 363–364HandleExceptionDemo.java, 579–580Handlers, 467, 486, 900Hand-tracing a program, 58Hard disks, 6Hardware, defined, 4Has-a relationship, 320, 390hashCode method, 323, 717

Object class, 323HashMap class, 716–718HashSet class, 716–718

Set interface, 716–718TestHashSet.java, 717–718

Hashtable, 735hasNext() method, Iterator interface, 724<head> tag, HTML, 539headMap() method, SortedMap interface, 734Heap sort, 755–759

analysis, 759–760HeapSort.java, 758–759height of a heap, 759implementation, 758–759initial heap, creating, 757–758makeHeap method, 759merge sort vs., 759method for making a heap, 758rebuildHeap method, 759rebuilding a heap:

algorithm for, 758method for, 757

sorting an array from a heap, 756–757Heap.java, 686–687Heaps, 660, 683–689

adding a new node, 684, 687defined, 683Heap class, 685–687new node, adding, 684–685removing the root, 684, 687representing, 684root, removing, 684TestHeap.java, 687–688

Heavyweight components, 401Height, 440Helper classes, 402Hertz (Hz), 5Hexadecimal numbers, 11

conversions between decimal numbers and,12–13

hgap property, BorderLayout manager, 412Hidden variables, 236HidingDemo.java, 326–327High-level languages, 8–9Histogram.java, 523–524Hoare, C. A. R., 752HoldComponents.java, 290Horizontal alignment, buttons, 494Horizontal text position, buttons, 495Horizontal wrap layout, lists, 1026House class, 355–356

House.java, 354–355hsbPolicy parameter, JScrollPane, 944hspace attribute, <applet> tag, HTML, 540HTML:

<applet> tag, 539–544syntax for, 539

<title> tag, 539attributes, 539<body> tag, 539defined, 539end tag, 539<head> tag, 539<html> tag, 539start tag, 539tags, 539

HTML files, placing, 1172HTML forms, 1159, 1170–1176

defined, 1170<form> … </form> tags, 1172<input> tag, 1172<label> … </label> tags, 1172obtaining current time based on locale and time

zone, 1174–1176obtaining parameter values from, 1172–1174<option> … </option> tags, 1172<select> … </select> tags, 1172Student_Registration_Form.html, 1171<textarea> … </textarea> tags, 1172

HTML/XHTML tutorial, 1170HttpServlet class, 1157, 1166, 1213

doDelete method, 1166doGet method, 1166doOptions method, 1166doPost method, 1166doPut method, 1166doTrace method, 1166UML class diagram, 1167

HttpServletRequest interface, 1166–1167,1213

UML class diagram, 1167HttpServletResponse interface, 1168, 1213

UML class diagram, 1168HttpSession interface, 1190–1195

RegistrationWithHttpSession.java, 1190–1195UML class diagram, 1101

Hypertext Markup Language (HTML), 14Hyper-Text Transport Protocol (HTTP), defined,

1180

IIBM DB2, 1099IBM Informix, 1099icon property, 970iconImage property, JFrame, 919Icons, 492–494

sharing, 418Identifiers, 30–31IdentifyHostNameIP.java, 823IEEE 754 standard, 34if ... else statements, 74–75, 89if statements, 73, 89, 131

if ... else statements, 74–75nested, 76–78simple, 73–74

IllegalArgumentException, 412, 582,582–583, 587, 589

IllegalMonitorStateException, 796–797Image file format, 418Image files, naming, 418Image icons, 418–419, 970–971

borders/icons, sharing, 418sharing borders and, 419TestImageIcon.java, 418–419

ImageContent.java, 1195–1196

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1288

Page 9: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1289

ImageContentWithDrawing.java, 1197–1199ImageIcon class, 947ImageObserver interface, 451ImageViewer class, 452–455

ImageViewer.java, 454–455SixFlags.java, 453–454stretchable image, 452UML class diagram, 453

ImageViewer.java, 454–455<img> tag, 1195–1196, 1199Immutable class, 232–233, 358–359Immutable objects, 232–233Immutable strings, 263–264Implementation, software development process, 372implements (keyword), 350Implicit casting, 43, 313import attribute, page directive, 1216Import on demand declaration, 157Improved math learning tool (example), 80–81include directive, 1216Increment operators, 38–39, 60Incremental development and testing, 30Indentation, 56, 76

indent code, 56Index, 171, 173, 175, 193Indexed variables, 171indexOf method, 267–268IndexOutOfBoundsException, 580, 582, 586InetAddress class, 822–823

IdentifyHostNameIP.java, 823Infinite loops, 97Infinite recursion, 637Information hiding, 147, 159Inheritance, 301–339, 376, 608, 675

aggregation vs., 389–390and classes, 377defined, 302GUI components, 330–331multiple, 342single, 342

init method:Applet class, 565Servlet interface, 1165

Initial capacity, 275Initial heap, creating, 757–758Initialization blocks, 327–330InitializationDemo.java, 328–329Initializers, 172Inner class, 485

anonymous, 471–472combining dependent classes into a primary

class, 485declaring, 470defined, 469objects of, 470SimpleEventDemoInnerClass.java, 470–471static, 470

Inner class listeners, 469–471InnerClass class, 469–470Inorder traversal, 679Input and output devices, 4, 6–7

keyboard, 6–7Input dialogs, 45–46, 985–986

defined, 982, 985Input errors, 57Input stream, 606<input> tag, 1172InputEvent class, 477InputMismatchException, 579InputStream class, 608–609InputStream class, 818

UML class diagram, 608Insert key, 7Insertion order, 734Insertion sort algorithm, 746

Insertion sort, analyzing, 746InsertionSort.java, 191, 746insertRow() method, 1136Insets class, 942Instance, 214Instance methods, 217

overriding, 309Instance variable, 217, 224instanceof operator, 314Instantiation, 214int, 32, 34, 89Integer class, 270, 356–357

parseInt method, 359Integer division, 35, 60Integer literals, 36–37Integer overflow exceptions, 582Integer vs. decimal division, 38IntegerMatrix class, 706IntegerMatrix.java, 708Integer.parseInt method, 46Integers, 34, 59Integrated development environment (IDE), 17,

175debugging in, 58, 78, 97, 133, 220

Integrity, relational database systems, 1094Integrity constraints, 1095–1098

defined, 1095domain constraints, 1096enforcing, 1097–1098foreign key constraints, 1097primary key constraints, 1096–1097types of, 1096

Interfaces, 212, 347–356abstract classes vs., 350–352accessing constants, 341Cloneable interface, 354–356compiling, 348conflict, 342custom, creating, 342–343declaring, syntax for, 348defined, 347and generic programming, 350marker, 354

intern method, 264Internal frames, creating, 999–1000International character encoding, 1176International clock:

calendar, displaying, 870–875CalendarApp.java, 874–875CalendarPanel.java, 871–873showDayNames method, 873showDays method, 873showHeader method, 873

displaying, 867–870WorldClockApp.java, 870WorldClockControl.java, 868–869WorldClock.java, 867–868

International time, displaying, 1225–1228DisplayTimeForm.jsp, 1226–1227DisplayTime.jsp, 1227TimeBean.java, 1226

Internationalization, 861–894Calendar class, 864character encoding, 888–889common country codes, 863common language codes, 863Date class, 864DateFormat class, 865–875international clock, displaying, 867–870Java features supporting, 862Locale class, 862–864numbers, formatting, 875–881ResourceBundle class, 862, 882, 890TimeZone class, 864–865Unicode, 862–864

Interned strings, 263–264, 292Internet, defined, 14, 816Internet Protocol (IP), 816

address, 816Internet Service Provider (ISP), 816Inter-relational, defined, 1096interrupt() method, 804InterruptedException, 778intValue() method, 356–357InvalidRadiusException.java, 592–593I/O (input/output), 575–603

and Java, 606IOException, 580–581, 581, 583, 585, 590, 592IP address, 816is null operator, 1102–1103Is-a relationship, 320, 342, 376

non-extensible is-a, 377isAlive() method, 804isEmpty method, 320

Collection interface, 716Map interface, 733

isErrorPage attribute, page directive, 1216isFocusable property, 482Is-kind-of relationship, 342, 390isLeapYear, 149isLeapYear(int year) method, 151isLetterOrDigit(ch) method, 271isLetterOrDigit(ch) method, 275isPalindrome method, 641–642isThreadSafe directive, 1216ItemEvent, 466, 467, 509ItemListener interface, 467Iteration, recursion vs., 649Iteration of a loop, 96Iterator interface, 729

hasNext() method, 724next() method, 724remove() method, 716UML class diagram, 715

iterator method, 716

Jjakarta-tomcat-5.5.9.zip, 1159JApplet, 402, 403, 538, 919–920JApplet, 538Java, 8

applets, 14, 17, 535–574using Swing components in, 538

application program interface (API), 16blocks, 21built-in monitor, 796–797bytecode file, 19case sensitivity of, 21, 31class names, 17classes, 21console output, 17design characteristics, 14history of, 14, 16language specification, 16main method, 17methods, 22modifiers, 21programs:

case sensitivity of, 19comments, 20–21creating, compiling, and executing, 18–20reserved words (key words), 21

statements, 21Student.java, 829–830, 1229–1230StudentServer.java, 833–834syntax rules, 18versatility, 14–15wrapper classes, 270, 358

Java 2 Enterprise Edition (J2EE), 16

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1289

Page 10: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1290 Index

Java 2 Micro Edition (J2ME), 16Java 2 Standard Edition (J2SE), 16Java archive file format (JAR), 563Java bytecode, 9Java Coding Style Guidelines, 55Java Collection Framework, 714–743

Comparator interface, 721–723defined, 714design of, 715lists, 723–726maps, 733–737priority queues, 731–733queues, 731–733relationships of the interfaces and classes

in, 714sets, 716–721singleton and unmodifiable collections and

maps, 737–738Stack class, 729–730Vector class, 729–730

Java Collections Framework, 390, 661defined, 714

Java database programming, 1093–1123advanced, 1125–1156

Java Development Toolkit (JDK), 16–17command-line debugger ( jdb), 58foreach loop, 174, 718javadoc command, 21PriorityQueue class, 732and supplementary characters, 42

Java development tools, defined, 17Java directory separator (/), 285Java event model:

elements, 900event classes, 900event listener interface, 900event pair, 900event set, 900

custom, creating, 906–911listener components, 901–902review, 900–902source components, 900–901

custom, creating, 902–906TestSourceListener.java, 901–902

Java GUI API, 404–405Java I/O programming, illustration of, 606–607Java language specification, defined, 17Java programming, 108Java programming-development process, 18Java projects:

archived projects, running, 563–564manifest file, 563packaging and deploying, 562–564

Java Runtime Environment (JRE), 563Java servlets, 15, 17Java source file, 19Java style, 960Java Virtual Machine (JVM), 9, 312, 1160JAVA_HOME environment variable, 1163java.applet.Applet, 536, 538, 559java.awt package, 291, 401, 403java.awt.Applet class, 918java.awt.Color class, 412java.awt.Component, 412, 416, 420, 501, 899,

911, 918, 928, 961java.awt.Container, 405, 415–416, 918,

921, 939java.awt.Dialog class, 918, 992java.awt.event package, 465java.awt.event.ActionListener interface, 342java.awt.event.ContainerEvent, 918java.awt.Frame class, 408, 918java.awt.GraphicsEnvironment, 413java.awt.Panel, 401

java.awt.Point, 477java.awt.Window, 401JavaBeans:

accessor (get) methods, 898class as JavaBeans component, 1219component, creating an instance for, 1219components, 898

defined, 898minimum JavaBeans component require-

ments, 898ComputeLoan2.jsp, 1223–1224Count.java, 1220–1221Count.java (revised version), 1221–1222defined, 898event registration, 898FactorialBean.java, 1224–1225FactorialBean.jsp, 1225international time, displaying, 1225–1228

DisplayTimeForm.jsp, 1226–1227DisplayTime.jsp, 1227TimeBean.java, 1226

mutator (set) methods, 898properties of:

associating with input parameters,1223–1232

and data fields, 899getting/setting, 1222–1223

property-naming patterns, 899and Serializable interface, 898student registration:

GetRegistrationData.jsp, 1231StoreData.java, 1228–1229StoreStudent.jsp, 1231–1232

syntax for creating a bean, 1220TestBeanScope.jsp, 1221using in JSP, 1219–1222

javac, 563javadoc command, JDK, 21javadoc comments, 21, 55java.io.File class, 284, 288java.io.FileNotFoundException, 609java.io.IOException, 610java.io.Reader class, 289java.io.Writer class, 289java.lang package, 392, 1215java.lang.Class, 325java.lang.Cloneable interface, 354–356java.lang.Comparable interface, 342, 348,

694, 699java.lang.Math, 154java.lang.Number class, 580java.lang.Object class, 302, 310, 331, 356java.lang.String class, 262–263, 283java.lang.StringBuffer class, 273java.lang.Throwable class, 585–586, 592, 596java.lang.UnsupportedOperationException,

716Collection interface, 716

java.net.BindException, 817, 822java.net.ConnectException, 822java.net.URL class, 558java.rmi.Remote interface, 1244JavaServer Pages (JSP), 15, 1209–1241

actions, 1211application variable, 1214browsing database tables (case study),

1232–1238BrowseTable.jsp, 1236–1237DBBean.java, 1233–1235DBLogin.html, 1235DBLoginInitialization.jsp, 1235–1236Table.jsp, 1236

comments, 1212ComputeLoan.html, 1214–1215

ComputeLoan.jsp, 1215config variable, 1214declarations, 1211defined, 1210directives, 1211, 1215–1219error pages, using (example), 1217–1219

ComputeFactorial.jsp, 1218–1219FactorialInputError.jsp, 1219FactorialInput.html, 1218

exceptions, 1232expressions, 1211Factorial.jsp, 1212forwarding requests from, 1232importing classes (example), 1216–1217

ComputeLoan1.jsp, 1216–1217include directive, 1216JSP files, storing, 1210JSP implicit objects, 1213JSP tags, 1210out variable, 1213page directive, 1216page variable, 1214pageContext variable, 1214predefined variables, 1213–1215, 1238processing of, 1211request variable, 1213response variable, 1213scripting constructs, 1211, 1211–1213

syntax, 1237–1238scripting elements, 1211scriptlets, 1211, 1213session variable, 1213tablib directive, 1216translated into a servlet, 1211using JavaBeans in, 1219–1222

java.swing.ButtonGroup, 501java.swing.event package, 465java.text.DateFormat, 864–865, 890java.text.DateFormatSymbols, 866java.text.ParseException, 877java.util package, 392java.util.ArrayList, 316–319, 695, 805, 905,

910, 1029java.util.Arrays, 191–192, 362, 744, 752java.util.Calendar, 345java.util.Calendar, 345java.util.Collections, 744java.util.Comparator interface, 721java.util.ConcurrentModification-

Exception, 805java.util.date, 222–223, 243java.util.EventListener, 900java.util.EventObject, 465, 484, 900java.util.Formatter, 289java.util.GregorianCalendar, 345java.util.Hashtable, 734java.util.InputMismatchException, 579java.util.Observable class, 1008java.util.Observer interface, 1008java.util.Random, 223java.util.Scanner, 289java.util.Stack, 730, 805java.util.TimeZone, 864javax.servlet, 1164javax.servlet.http, 1164javax.servlet.http.Cookie, 1185javax.swing package, 392, 402javax.swing.AbstractButton, 492javax.swing.BorderFactory class, 954

UML class diagram, 954javax.swing.event package, 515javax.swing.event.ListSelectionEvent, 513javax.swing.event.ListSelectionListener

interface, 513

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1290

Page 11: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1291

javax.swing.JApplet, 538javax.swing.JComponent, 921javax.swing.JGlassPane, 919javax.swing.JLayeredPane, 919, 961javax.swing.JRootPane, 919, 961javax.swing.JTable, 1046javax.swing.SwingConstants interface, 495javax.swing.Timer, 482javax.swing.tree, 1069javax.swing.UIManager, 960JBuilder (Borland), 17, 18, 58, 78, 97, 133, 175,

220, 898, 1011, 1163JButton, 247–248, 400, 405, 415, 466, 468, 493,

898, 900–901, 1015, 1016JCheckBox, 400, 466, 498, 1016JCheckBoxMenuItem, 1001

adding to a JMenu, 968–969JColorChooser, 992–994

color preview panel, 993flexibility of, 994tabbed pane, 993

JComboBox, 247–248, 400, 402, 466, 509–511,1035–1038

ComboBoxCellRendererDemo.java, 1037–1038defined, 1036events generated by, 509–510UML class diagram, 509, 1036

JComponent, 402, 431, 952extending, 431

JCreator LE, 17JDBC, 1106–1113

accessing a database from a Java applet,1111–1113

accessing the database, steps in, 1106classes12.jar, 1107–1108Connection interface, 1113, 1116, 1120DatabaseMetaData interface, 1116–1117, 1120defined, 1106developing database applications using,

1107–1108drivers, 1108

loading, 1107–1108FindGrade.java, 1111–1112image retrieval, 1150image storage, 1150interfaces and classes, 1106JDBC 2 standard, 1126JDBC 3 standard, 1126mysqljdbc.jar, 1107–1108ResultSet, processing, 1109–1110ResultSetMetaData interface, 1116retrieving metadata, 1116–1119SimpleJDBC.java, 1110statements:

creating, 1109executing, 1109

StoreAndRetrieveImage.java, 1151–1153storing and retrieving images in, 1150–1153URLs, 1108

JDBC-ODBC driver, 1177JdbcRowSet, 1145JDialog, 403JEdit, 17JEditorPane, 836–838JFileChooser, 994–998

properties of, 994–995JFrame, 247–248, 290, 402, 403, 415, 417, 544,

919–920content pane, 405contentPane property, 919iconImage property, 919jMenuBar property, 919properties of, 1000resizable property, 919

title property, 919UML class diagram, 404

JGlassPane, 919JGrasp, 17JInternalFrame, properties of, 1000JLabel, 400, 503, 538

constructors/methods, 503UML class diagram, 503

JLayeredPane, 919, 961, 1000jlblBanner, 428JList, 247–248, 402, 466, 512–513, 1024–1029

constructors, 1025JList.HORIZONTAL_WRAP, 1026JList.VERTICAL, 1025JList.VERTICAL_WRAP, 1026layoutOrientation property, 1025–1026list cell renderer, 1032–1035list layout orientations, 1025–1026list model, 1025, 1029–1032list models, 1029–1032list properties demo, 1027list-selection model, 1025methods, 1025properties, 1025selection modes, 512–513selectionMode property, 1026selectionModel property, 1026UML class diagram, 512, 1025

JMenu, 402JMenuBar, 1001

defined, 968jMenuBar property, JFrame, 919JMenuItem, 466, 1001join() method, 779JOptionPane:

defined, 22dialogs, 982–988

creating (example), 982–989showInputDialog method, 45, 52showMessageDialog method, 22–23, 130

JOptionPaneDemo.java, 986–988JPanel, 402, 403, 413–414, 430, 451, 479, 920,

947, 1011defined, 403

JPasswordField, 506JPEG (Joint Photographic Experts Group), 418JPopupMenu, 974JProgressBar, 402, 805–808

CopyFile.java, 807–808UML class diagram, 806

JRadioButton, 247–248, 400, 402, 466, 501UML class diagram, 501

JRadioButtonMenuItem, 969–970, 1001JRootPane, 919, 961JScrollBar, 466, 515–518

properties of, 516UML class diagram, 516

JScrollPane, 943–947CornerPanel class, 947defined, 943hsbPolicy parameter, 944ScrollMap.java, 945–947setCorner() method, 944UML class diagram, 945viewport, 943–944vsbPolicy parameter, 944

JSlider, 518–521features of, 521UML class diagram, 519

JSP, See JavaServer Pages (JSP)JSP files, storing, 1210JSP implicit objects, 1213JSP tags, 1210JSpinner, 1016–1018

defined, 1016methods, 1017–1018sequence value, 1017UML class diagram, 1017

JSplitPane, 949–952defined, 949divider, 949ShowLayout.java, 949–951UML class diagram, 951

JTabbedPane, 947–949defined, 947DisplayFigure.java, 948–949ease of use, 948UML class diagram, 948

JTable, 1008, 1016, 1019, 1046–1068, 1136,1144, 1156

column model, 1046constructors, 1047defined, 1046JTableHeader class, 1046list-selection model, 1046methods, 1047properties, 1047and scrolling, 1046table data model, 1051table model, 1046TableColumn class, 1046TablePropertiesDemo.java, 1048–1050TestTable.java, 1047–1048UML class diagram, 1047

JTableHeader, 1054–1055UML class diagram, 1055

JTextArea, 402, 506JTextComponent, 504, 506JTextField, 400, 402, 466, 504, 506JToggleButton, 498, 1016JToolBar, 976–978JToolBar:

floatable property, 977orientation property, 977

JTree, 1008, 1016, 1068–1085constructors, 1069–1070, 1072defined, 1068editable property, 1084leaf, 1069methods, 1069–1070nonleaf node, 1069properties, 1069–1070root, 1069and scrolling, 1072SimpleTreeDemo.java, 1070–1072subtrees, 1069supporting interfaces and classes, 1069tree events, 1085treelike hierarchy, 1068trees, 1069

data representation of, 1069UML class diagram, 1070

JViewport, 943JVM (Java Virtual Machine), 9

KKey events, 479–482, 484

key constants, 481KeyboardPanel class, 482KeyEventDemo.java, 480

Key K, 1097Key words, 21KeyAdapter, 476Keyboard, 6–7Keyboard accelerators, 970–971Keyboard mnemonics, 970–971KeyEvent, 466, 467

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1291

Page 12: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1292 Index

KeyListener interface, 467KeyAdapter, 476

keyPressed handler, 479keyReleased handler, 479Keys, 882–883keySet method, Map interface, 733KeyStroke class, getKeyStroke method, 970KeyStroke object, setAccelerator method, 970keyTyped handler, 480Keywords, SQL, 1098Koch snowflake, 655

L<label> … </label> tags, 1172Labels, 503–504

breaking with, 115–116Language, relational database systems, 1094Language codes, 863lastIndexOf method, 267lastKey() method, SortedMap interface, 734lastModified() method, 285Layout managers, 290, 406–412

BorderLayout manager, 410–412BoxLayout manager, 930–933CardLayout manager, 921–924custom, creating, 938–943

DiagonalLayout.java, 940–942ShowDiagonalLayout.java, 942–943

defined, 406FlowLayout manager, 406–408GridBagLayout manager, 924–928GridLayout manager, 408–410OverLayout manager, 933–936properties of, 920SpringLayout manager, 936–938using no layout manager, 928–930

ShowNoLayout.java, 929–930layout property, Container class, 918layoutContainer method, 938–939, 943LayoutManager interface, 403, 938–939, 943, 961layoutOrientation property, 1025–1026Lead path, 1078Leading, 440Leap year, determining (example), 71–72LeapYear.java, 68–69Learning Java Effectively with

JBuilder/NetBeans/Eclipse, 59, 175, 220Left-associative, 86Length, arrays, 171length() method, 265–266

StringBuffer class, 275Life-cycle methods, 1165Lifeline, 390Lightweight components, 401like operator, 1102–1103Line comment, 20Line separator, 286Linear search, and large arrays, 185Linear search approach, 186linearSearch method, 186LinearSearch.java, 186LineBorder class, 952–953Lines, drawing, 431–432lineWrap property, 509LinkageError subclass, Error class, 581Linked lists, 668–675

MyLinkedList.java, 669–672nodes, 668

Linked structure, 661LinkedHashMap class, 734–736, 739, 742LinkedHashSet class, 714, 718–719, 738

Set interface, 718–719TestLinkedHashSet.java, 718–719

LinkedList class, 724–726defined, 724TestArrayAndLinkedList.java, 725–726UML class diagram, 725

LinkedList queue, 731List cell renderer, 1032–1035

ListCellRendererDemo class, 1032ListCellRendererDemo.java, 1034–1035

List interface, 723–724AbstractList class, 724add() method, 723addAll() method, 723ArrayList class, 724–726indexOf() method, 723lastindexOf() method, 723LinkedList class, 724–726listIterator() method, 723remove() method, 723UML class diagram, 723

List layout orientations, 1025–1026List models, 1025, 1029–1032

ListModelDemo.java, 1031–1032List properties demo, ListPropertiesDemo.java,

1027–1028ListCellRenderer interface, 1032–1035, 1036

ListCellRendererDemo.java, 1034–1035MyListCellRenderer.java, 1033–1034, 1037

ListDataListener, 1029ListDemo.java, 514–515Listener components, 901–902Listeners, 363, 465–477, 486

ActionListener interface, 467defined, 465, 900inner class, 469–471listener interface adapters, 476MouseMotionListener interface, 467registration methods, 468Window events, handling, 474–475XEvent, 467XListener interface, 467

ListIterator interface, 723add() method, 723hasnext() method, 724next() method, 724nextIndex() method, 724previous() method, 724previousIndex() method, 724UML class diagram, 723

ListModel interface, 1036methods defined by, 1029UML class diagram, 1030

ListResourceBundle class, 882, 888Lists, 28, 512–515, 659–675, 714

array lists, 663–668ascending order, 726–7and binarySearch method, 727and copy() method, 728defined, 512, 660, 661descending order, 726–727and disjoint method, 726, 729and fill() method, 728and frequency method, 726Java Collection Framework, 723–726JList, 512linked lists, 668–675ListDemo.java, 514–515and max method, 729and min method, 729MyAbstractList.java, 662–664, 666–668MyList.java, 661–662and nCopies() method, 728operations of, 660and reverse method, 728scrolling, 513

and shuffle() method, 728sorting comparable elements in a list, 726static methods for, 726–729TestList.java, 667–668

List-selection model, 1025JTable, 1046

ListSelectionEvent, 466, 515ListSelectionListener interface, 515ListSelectionModel interface, 1026Literals, 36

defined, 36Loan class, 239–240, 1216–1217

implementation, 241–243Loan payments, computing, 46–47LoanApplet.html, 543–544LoanApplet.java, 542–543

with main method, 545–546public modifier, 543

Loan.java, 241–242Local area networks (LANs), 7, 816Local object types, 1245–1246Local objects, 1244Local variables, 235

defined, 141scope of, 141–142

Locale class, 862–864, 880country, 862getAvailableLocales() method, 864language, 862locale property in Component class, 862locale-sensitive operation, 864predefined locale constants, 864UML class diagram, 863variant, 862

Locale-sensitive operation, 880LocateRegistry class, 1246Locks, 790–796

AccountWithSyncUsingLock.java, 791–792fairness policies, 791ReentrantLock class, 791

Logarithmic algorithm, 745Logic errors, 58, 60, 578

debugging, 58Logical operators, 69long, 32, 34, 37, 89Long class, 270, 356LONG constant, DateFormat class, 865Long string, breaking, 30longValue() method, 356–357Loop body, 96Loop statements, 39loop-continuation-condition, 96–97, 118

omission of, in for loop, 103–104Loops, 95–127

case studies, 108–113controlling a confirmation dialog, 98–99controlling with a sentinel value, 99–100defined, 96do-while loop, 100–101, 111infinite, 97iteration of, 96for loop, 102–104nested, 105while loop, 96–100

Lower bound wildcards, 701

MMachine languages, 7Main class, 215Main memory, 4main method, 17, 22, 130, 132–134, 136, 144, 149

and applets, 536, 545–546, 549Main window, 521

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1292

Page 13: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1293

Maintenance, 373makeHeap method, 759MalformedURLException, 834Manifest file, 563Map, 714Map interface, 733–737

AbstractMap class, 733–734query methods, 733TestMap.java, 735–736UML class diagram, 734update methods, 733

Maps, 733–737singleton, 737–738unmodifiable, 737–738

Marker interfaces, 354matches method, String class, 280Matching a method signature vs. binding a method

implementation, 312Math class, 142–143, 142–145, 321

exponent methods, 143min, max, and abs methods, 144random method, 144rounding methods, 143–144trigonometric methods, 142

Math subtraction learning tool program, 97–98MatteBorder class, 952–953, 959max method, 131, 133, 348, 729

and lists, 729Math class, 144

Max1.java, 700maximumsize property, Container class, 920Max.java, 699maxlength attribute, <input> tag, 1172mbps (million bits per second), 7MEDIUM constant, DateFormat class, 865Megabytes (MB), 5Megahertz (MHz), 5Memory, 5–6, 10–11

main memory, 4Memory chips, 5Memory unit, 5MenuDemo.java, 971–974Menus, 968–976

associating with the menu bar, 968check box menu items, creating, 969creating, 968–970defined, 968, 1001image icons, 970–971keyboard accelerators, 970–971keyboard mnemonics, 970–971menu items, 968–969popup, 974–976radio button menu items, creating, 969–970sequence of implementing, in Java, 968submenu items, creating, 969using, 971–974

Merge sort, 749–754heap sort vs., 759illustration, 749–754MergeSort.java, 750–751merging two arrays, method for, 749–750quick sort vs., 759time, 751–752time analysis, 751

Merge sort algorithm, 749MergeSort.java, 750–751Message dialog box, displaying text in, 22–23Message dialogs, 983

defined, 982MessagePanel class, 442–446, 495, 899

MessagePanel.java, 444–446reuse of class, 446TestMessagePanel.java, 442–443UML class diagram, 443

MessagePanel.java, 444–446, 498Metadata, retrieving, 1116–1119

database metadata, 1116–1117database tables, obtaining, 1117–1118ResultSetMetaData interface, 1116,

1118–1119Metal style, 959–960Meta-object, 325Method abstraction, 130, 153, 159

defined, 146and stepwise refinement, 146–154

method attribute, <form> tag, 1172Method block, 21Method body, 130–131, 147Method declaration, 130Method invocation, 391Method name, 130, 132, 158Method overloading, 137Method overriding, 309, 331Method signature, 131, 133, 135, 137, 147, 158Methods, 214

abstraction, 130, 146–154ambiguous invocation, 139called method, 131, 158calling/invoking, 131–133computing taxes with (case study), 139–141creating, 130–131functions, 130invoking, 133, 138method body, 130–131, 147method declaration, 130method header, 158

formal parameters, 130method name, 130, 132, 158method signature, 131modifiers, 130naming, 55nonvoid method, 130overloading, 138parameters, 130procedures, 130return value type, 130, 158returnValueType, 130reusing, 133static, 23, 224static modifier, 130stepwise refinement, 147syntax, 130void method, 130

Microsoft Internet Information Server, 1159min method, and lists, 729min method, Math class, 144minimumsize property, Container class, 920MissingResourceException, 883MixedContent.java, 1199–1200mnemonic property, 970, 1015Modal, use of term, 988Model, components of, 1008model property, 1015Modeling behavior:

object-oriented design, 390–392sequence diagrams, 390–391statechart diagrams, 391–392

Model-view-controller (MVC) approach, 1008–1014benefits of, 1008MVCDemo.java, 1013–1014variations, 1014–1015

Modems, 4Modifier key, 7Modifiers, 21, 130, 158ModifyTree.java, 1081–1083Monetary units, counting (example), 48–49Monitors, 4, 6–7

built-in, 796–797

Motif:popup menus in, 1001style, 959–960

Mouse, 4, 6–7Mouse events, 477–479, 484

MouseEvent class, 477MoveMessageDemo.java, 478–479moving a message on a panel using a mouse,

477–479Point class, 477

MouseAdapter, 476mouseDragged method, 479MouseEvent, 466MouseEvent, 466, 467, 477, 479MouseListener interface, 467, 477, 479

MouseAdapter, 476MouseMotionAdapter, 476MouseMotionListener interface, 467, 477, 479,

486mouse-motion handlers, 479MouseMotionAdapter, 476

mouseMoved method, 479mousePressed method, 975mouseReleased method, 975MovableMessagePanel class, 479MoveMessageDemo.java, 478–479moveToInsertRow() method, 1136MovingMessagePanel class, 483–484MS Access, 1099Multidimensional arrays, 199–201Multimedia animations, 560–562multiple attribute, <select> … </select>

tags, 1172Multiple clients, 823–826

MultiThreadServer.java, 824–826Multiple declarations, 141Multiple document interface (MDI), 999, 1001Multiple generic parameters, 698Multiple inheritance, 342Multiple threads, and exception handling, 589Multiple windows, creating, 521–525

Histogram.java, 523–524MultipleWindowsDemo.java, 522–523, 525

MULTIPLE_INTERVAL SELECTION value:selectionMode property, 1026selectionModel property, 1026

Multiple-choice test, grading (example), 196–197Multiple-interval mode, JList, 512–513MultipleWindowsDemo.java, 522–523, 525Multiplication (*) operator, 35Multiplicity, 373multiplyMatrix method, GenericMatrix class,

705–706Multiprocessing, 11Multiprogramming, 11multiSelectionEnabled property,

JFileChooser, 995Multithreading, 11, 774

benefits of, 774defined, 774in single-processor systems, 774

MultiThreadServer.java, 824–826MutableComboBoxModel interface, 1036MutableTreeNode interface, 1069Mutator, 230, 249Mutator (set) methods, and JavaBeans, 898MVCDemo.java, 1013–1014MyAbstractList.java, 662–664, 666–668MyArrayList.java, 664–667myCircle, 216–220, 231–234, 252MyFrame.java, 404MyFrameWithComponents.java, 405MyImageCellRenderer.java, 1063MyLinkedList.java, 669–672

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1293

Page 14: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1294 Index

MyListCellRenderer.java, 1037MyList.java, 661–662MyPriorityQueue.java, 688MyQueue.java, 675–676MySQL, 1176

batch updates, 1131databasename command, 1100default databases, 1099mysql database, 1099–1100starting, 1099stopping, 1099test database, 1099tutorial, 1099

mysqljdbc.jar, 1107–1108MyStack class, 319–320

UML class diagram, 696MyStack.java, 319–320

Nname attribute:

<input> tag, 1172<select> … </select> tags, 1172<textarea> … </textarea> tags, 1172

Name.java, 379Naming conventions, 55–56

SQL, 1098Narrowing a type, 40, 60native modifier, 322, 355nCopies() method, and lists, 728Nested blocks, 21, 141–142Nested class, 485

defined, 469Nested if statements, 76–78Nested loops, 105Nested parentheses, in numeric expressions, 38NetBeans, 898, 1011NetBeans Open Source (Sun), 17, 18, 58, 78, 97,

133, 175, 220, 1163Netscape Enterprise Server, 1159Network interface cards (NICs), 4, 7Network programming, 816Networking, 815–860

applet clients, 826–829case studies, 838–850client/server computing, 816–822datagram sockets, 816, 850–856distributed TicTacToe games, 838–850InetAddress class, 822–823Internet Protocol (IP) address, 816JEditorPane class, 836–838multiple clients, 823–826stream sockets, 816Transmission Control Protocol (TCP), 816User Datagram Protocol (UDP), 816Web servers, retrieving files from, 834–836WebBrowser.java, 837–838

new GregorianCalendar(), 345new operator, 170, 172, 201, 216–7, 249, 344,

364, 392, 408and arrays, 217and constructors, 216

new Scanner(File), 288New state, threads, 803newCondition() method, 791, 793, 795–6newDeposit condition, 793newFixedThreadPool(int) method, 786NewPanel class, 430NewRecordDialog.java, 1143–1144next() method, Iterator interface, 724nextInt method, Scanner class, 579Next-line style, 56NICs, See Network interface cards (NICs)no-arg constructor, 388

and wrapper classes, 358

NoClassDefFoundError exception, 20Nodes, linked lists, 667–675Nonalphanumeric characters, ignoring

when checking palindromes, 275–277

Non-extensible is-a relationship, 377Nonleaf node, 1069Nonserializable fields, 619Nonvoid method, 130NoSuchMethodError, 20NotePad (Windows), 18–19NotSerializableException, 619npoints data field, 438null values, 220–221NullPointerException, 221, 578, 582Number class, 356, 359NumberFormat class, 875–876, 890

UML class diagram, 876NumberFormatDemo.java, 878–881NumberFormat.getInstance(), 876

getCurrencyInstance method, 877, 890getPercentInstance(), 877, 890

numberOfObjects, 224–226Numbers:

currency format, 877DecimalFormat Class, 877–878formatting, 875–881

example of, 878–881NumberFormatDemo.java, 878–881

NumberFormat class, 875–876, 890parsing, 359–360, 877percent format, 877plain number format, 876resource bundles, 881–888

Numeric data types, 34, 34–40Numeric errors, minimizing, 106–108Numeric expression, writing in Java, 37–38Numeric keypad, 7Numeric literals, 36–37

floating-point literals, 37integer literals, 36–37literals, defined, 36scientific notations, 37

Numeric operators, 35, 60on characters, 44in a Java expression, 38

Numeric type conversions, 40–41Numeric wrapper classes, 358–359

constants, 358constructors, 358conversion methods, 358–359static valueOf methods, 359

OOak, 14Object class, 302, 310–312, 355

methods in, 322–325clone method, 324–325equals method, 322–323finalize method, 322getClass Method, 325hashCode method, 323

toString() method, 310–311Object I/O, 617–620

TestObjectInputStream.java, 618TestObjectOutputStream.java, 617–618

Object member access operator, 217Object reference variables, 216Object serialization, 619ObjectInputStream, 617Object-oriented design, 371–396

aggregation, 374association, 373–374

dependency vs., 376

case study, 377–382Rational class, 382–387

class design guidelines, 387–390composition, 374dependency, 375–376framework-based programming using Java API,

392inheritance, 376modeling behavior, 390–392

sequence diagrams, 390–391statechart diagrams, 391–392

Object-oriented programming (OOP), 211–259defined, 214

ObjectOutputStream, 617UML class diagram, 617

objectRefVar.dataField, 217objectRefVar.method, 217objectRefVar.methodName, 220Objects, 214, 216

accessing data and methods of, 217–218accessing via reference variables, 216–222arrays as, 217behavior, 214and classes, 214creating, 218–220defined, 214defining classes for, 214–16establishing relationships among, 377identifying, 377invoking methods on, 214lifecycle of, and statechart diagrams, 392object reference variables vs., 217sending/receiving, 829–834state, 214using classes from the Java library, 222–224

Date class, 222–223Random class, 223–224

Observable class, 1008Observer inferface, 1008Octal numbers, 14ODBC data source, creating, 1108Off-by-one error, 175OKListenerClass, 365OOP, See Object-oriented programming (OOP)Open file dialog, 994Operand evaluation order, 87–88Operating systems (OSs):

allocating and assigning system resources, 10controlling and monitoring system activities, 10defined, 10scheduling operations, 10–11

operationMenu, 974Operator associativity, 86–87Operator precedence, 86–87Option dialogs, 986–988

defined, 982<option> … </option> tags, 1172Optional GUI sections, 212Oracle, 1176

batch updates, 1131tutorial, 1099

oracle.jdbc.driver.OracleDriver, 1108order by clause, SQL, 1105orientation property, JToolBar, 977Original Unicode, 42OSs, See Operating systems (OSs)out variable, JSP, 1213Outdated methods, 777OuterClass class, 469–470Output devices, 4, 6–7Output stream, 606OutputStream class, 608–609, 818

UML class diagram, 609Ovals, drawing, 431–432Overhead, 649

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1294

Page 15: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1295

OverlayLayout manager, 933–936OverLayout manager, 933–936

ShowOverLayLayout.java, 934–936Overloading methods, 137–141, 310Override accessible instance method, 309Overriding vs. overloading, 310

Ppack() method, 505package-access, 228package-private, 228Packages, 154–158

directories, 154–155hierarchical nature of, 154package-naming conventions, 154putting classes into, 155–156reasons for using, 154using classes from, 156–157

Packets, 850page directive, 1216Page down key, 7Page up key, 7page value, scope attribute, 1220page variable, JSP, 1214pageContext variable, JSP, 1214paintComponent method, 429, 451, 479, 1011

invoking directly, 435protected visibility, 430super.paintComponent(g), 430

PalindromeIgnoreNonAlphanumeric.java, 276–277Palindromes:

checking, 269–270ignoring nonalphanumeric characters at time

of, 275–277Panels:

TestPanels.java, 414–415using as subcontainers, 413–415

Paragraph comment, 20Parallel processing, 11param attribute, Applet class, 565Parameter list, 130, 138, 158Parameter order association, 135Parameters, 130, 158

defined, 130method, scope of, 141

Parent class, 302, 331Parentheses:

array elements and, 171order of evaluation and, 89

parseDouble method, Double class, 46Double class, 359

parseInt method, Integer class, 46Parsing numbers, 359–60, 877Pascal, 8Pass by value, defined, 135Passing arrays to methods, 179–181Passing objects to methods, 233–234Passing parameters, 1245–1246Passing parameters by values, 135–137peek() method, 320

Stack class, 730Peers, 401Percent format, 877Perl language, 1159Person.java, 380–381Pivot, 752Pixels, 7, 405Plain number format, 876Pluggable look-and-feel feature, 960–961PNG (Portable Network Graphics), 418Point class, 477, 649Polygon class, 438–439

drawPolygon method, 439drawPolyline method, 439

Polygon object, 438Polygons, drawing, 438–440polyLine method, 439Polylines, drawing, 438–440Polymorphism, 311–313

defined, 312demonstrating, 314–315and generic programming, 313

PolymorphismDemo.java, 311–312pop() method, 320

Stack class, 730pop(o) method, 677Popup menus, 974–976

defined, 974PopupMenuDemo.java, 975–976showing, 974–976simplifying, 976

Popup triggers, 974–976, 1001POST method, 1159–1160Postdecrement operator, 39Postincrement operator, 39Postorder traversal, 679Post-test loops, 104pow(a, b) method, Math class, 47Precedence rule, 86–87Predecrement operator, 39Predefined variables, 1213–1215, 1238preferredsize property, Container class, 920Preincrement operator, 39Preorder traversal, 680PreparedStatement interface, 1113–1116

FindGradeUsingPreparedStatement.java,1114–1116

and RowSet, 1147Pressed icons, 492–494Pre-test loops, 104Primary key, 1097Primary key constraints, 1096–1097Prime numbers, displaying (example), 116–117PrimeNumber.java, 117–118Primitive data types, 28, 34, 60, 88, 1245

processing values as objects, 356–357variables of, 221–222

print method, println method vs., 53printAreas method, 234printCalendar problem, 148PrintCalendar.java, 148–154

implementation details, 151–154PrintChar class, and Runnable, 777printCircle method, 233–234printCircle method, 233–234printCircleArray, 239Printers, 4, 6–7PrinterWriter class, 289printf method, 84–85printGrade method, 134–135println method, 22, 52, 135printMonth, 149–150printMonthBody, 148printMonthTitle, 148printNum class, 777PrintPyramid.java, 112–113printStackTrace() method, 585–586, 590PrintWriter class, writing data using, 286–287,

292Priority queues, 688–689, 731–733

defined, 688MyPriorityQueue.java, 688TestPriorityQueue.java, 688–689

PriorityQueue class, 732PriorityQueueDemo.java, 732–733Private constructor, 229Private data fields, 228

in a superclass, 309private (modifier), 21, 228, 320–321

Procedural languages, 214Procedural programming, 214Procedures, 130–131processSQLNonSelect() method, 1130processSQLSelect method, 1130Producer/consumer (case study), 797–799

ConsumerProducer.java, 797–799Program control, 113, 118, 158Programming:

usefulness of remainder in, 35using a native machine language, 7–8

Programming errors, 57–58, 60Programming languages, 30

coding, 28Programming style, 55–57

defined, 55Programs, 7–8Progress bar, defined, 805–808Properties, 214Property-naming patterns, JavaBeans, 899PropertyResourceBundles, 888protected (modifier), 332, 355

data and methods, 21, 320–321Pseudocode, 68public (modifier), 21, 228push() method, Stack class, 730push(o) method, 677put method, Map interface, 733putAll method, Map interface, 733Pyramid of numbers, displaying (example),

111–112

QQuadratic algorithm, 748Quantifiers, 280Query string, 1159Queue interface, 731–733

element method, 731offer method, 731peek method, 731poll method, 731remove method, 731UML class diagram, 731

Queues, 660, 675–677, 731–733defined, 675LinkedList class, 731MyQueue.java, 675–676operations, 731priority, 688–689PriorityQueue class, 732PriorityQueueDemo.java, 732–733Queue interface, 731–733TestQueue.java, 731–732TestStackQueue.java, 676–677

Quick sort, 752–755algorithm, 752average-case time, 757best-case time, 757defined, 752illustration, 752merge sort vs., 757partition illustration, 756partition method, 753–755partition time, 757partitioning, 752pivot, 752QuickSort.java, 756–757time, 757worst-case time, 757

RRace condition, 789Radio button menu items, creating, 969–970

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1295

Page 16: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1296 Index

Radio buttons, 501–503JRadioButton, 501RadioButtonDemo.java, 502–503

radio input type, 1172radius, 214–217Radix, 11Ragged arrays, 194–195RAM (random-access memory), 5Random access files, 621–623

file pointer, 622read-only streams, 621TestRandomAccessFile.java, 622–623write-only streams, 621

Random characters, generating (case study),145–146

Random class, 223–224random method, 81

Math class, 144RandomAccessFile class, 621

UML class diagram, 621RandomCharacter.java, 146Rational class, 372, 382–387

encapsulation, 386–387as immutable class, 387Rational.java, 384–386TestRationalClass.java, 384

Rational number, defined, 382Rational.java, 384–386RationalMatrix class, 706RationalMatrix.java, 708–709Raw type, 699

Max1.java, 700Max.java, 699unsafe, avoiding, 703–705

readBoolean method, 621readChar method, 621ReadData.java, 287–288readDouble method, 621readInput, 149readInt method, 621–622Read-only property, 900Read-only streams, 621readUTF method, 612, 621Ready state, threads, 803rebind method, 1246rebuildHeap method, 759Rebuilding a heap:

algorithm for, 758method for, 757

receive(packet) method, 851DatagramSocket class, 851

Rectangle class, 302and GeometricObject class, 302

Rectangle.java, 305, 344Rectangles, drawing, 431–432Recursion, 2, 635–655

base cases, 640binary search, 642–643characteristics, 640defined, 636, 649, 650factorials, 638–639

ComputeFactorial.java, 637–638Fibonacci numbers, 638–640fractals, 646–649

defined, 646if-else, 640infinite, 637isPalindrome method, 641–642iteration vs., 649overhead, 649palindrome using a helper method,

641–642recursive binary search method, 643recursive call, 636, 640, 641

recursive helper methods, 636, 641–643defined, 642

recursive palindrome method, 641reduction, 640selection sort, 642

recursive sort method, 642thinking recursively, 641Tower of Hanoi problem, 643–646

Recursive call, 636, 640, 641Recursive method, defined, 636, 650ReentrantLock class, 791Reference data fields, 220–221Reference types, 44, 216

variables of, 221–222Reference variables, 216–222

accessing an object’s data and methods, 217–18accessing objects via, 216–222classes, declaring, 218–220differences between variables of primitive types

and reference types, 221–221reference data fields and the null value, 220–221

regionMatches method, String class, 265RegisterStudent3TierServer.java, 1255RegisterWithRMIServer.java, 1249Registration.html, 1182Registration.java, 1182–1185RegistrationWithCookie.java, 1186–1189RegistrationWithHttpSession.java, 1190–1195,

1191–1195Registry class, 1246Regular expressions, 269, 279–280

frequently-used, 281syntax, 280

Relational database systems, 1094–1098attributes, 1095components of, 1094integrity, 1094integrity constraints, 1095–1098language, 1094relational model, 1094–1095relational structures, 1094structure, 1094tables, 1095tuples, 1095

Relational operators, 68Relationships, 320Relative file names, 285Relative URL, using, 1172Reluctant match, 283Remainder, usefulness in programming, 35Remainder (%) operator, 35Remote interface, 1244Remote Method Invocation (RMI), 1243–1267

basics of, 1244–1246client, 1244client program, 1244defined, 1244developing three-tier applications using,

1253–1255how it works, 1244JDK1.5, 1245local object types, 1245–1246local objects, 1244passing parameters, 1245–1246primitive data types, 1245remote object types, 1246remote objects, 1244retrieving student scores from an RMI server

(example), 1246–1252RegisterWithRMIServer.java, 1249StudentServerInterfaceClient.java,

1250–1251StudentServerInterface.java, 1248,

1248–1249

RMI applications, developing, 1246–1252RMI callbacks, 1255–1265

CallBackImpl.java, 1261CallBack.java, 1257TicTacToeClientRMI.java, 1261–1264TicTacToeImpl.java, 1258–1260TicTacToeInterface.java, 1256–1257

RMI registry, 1244, 1246server, 1244server implementation, 1244server object, 1244server object interface, 1244server skeleton, 1244server stub, 1244socket-level programming vs., 1252

Remote object types, 1246Remote objects, 1244remove method, 939

Collection interface, 716remove method, Container class, 405remove() method, Iterator interface, 716remove method, Map interface, 733Remove Selected Nodes button, 1081, 1083removeAll method, Collection interface, 716removeLayoutComponent, 939repaint method, 435, 479replace method, 267, 274

strBuf, 274replaceAll method, 282replaceFirst method, 282ReplaceText class, 288–289request parameter, doGet method, 1161request value, scope attribute, 1220request variable, JSP, 1213requestFocusInWindow() method, 505Requirements specification, 372Reserved words (key words), 21resizable property, JFrame, 919Resolution, 405

monitors, 7Resource bundles, 881–888

defined, 882key/value pairs, 881naming conventions, 882resource chain, 882ResourceBundle class, 862, 882, 890ResourceBundleDemo.java, 884–888

Resource ordering, 803, 809deadlocks, 803, 809

ResourceBundle class, 862, 882, 890response parameter, doGet method, 1161response variable, JSP, 1213ResultSet:

constants, 1135methods, 1136processing, 1109–1110

resultSetConcurrency, 1135ResultSetMetaData interface, 1116, 1118–1119resultSetType, 1135retainAll method, Collection interface, 716return statement, 130

nonvoid method, 130–134void method, 134–135

Return value type, 130, 158returnValueType, 130revalidate() method, 921, 947reverse method:

and lists, 728strBuf, 274

RGB model, 412Right-associative, 87Rigid area, 931RMI applications, developing, 1246–1252RMI callbacks, 1255–1265

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1296

Page 17: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1297

RMI registry, 1244, 1246rollback() method, 1110Rollover icons, 492–494rootVisible property, 1069, 1070Rounding methods, Math class, 143–144rowChanged(RowSetEvent), 1149rowHeight property, 1070rows attribute, <textarea> … </textarea> tags, 1172Rows/columns, modifying, 1055–1060RowSet interface, 1145–1150

CacheRowSet, 1145connected RowSet object, 1145disconnected RowSet object, 1145get and set methods, 1145JDBC driver support, 1145JdbcRowSet, 1145metadata, obtaining, 1147and PreparedStatement, 1147RowSetPreparedStatement.java, 1147scrolling and updating, 1148SimpleRowSet.java, 1146versions of, 1145

RowSetEvent, 1149–1150RowSetListener, 1149RowSetPreparedStatement.java, 1147run() method, Runnable interface, 774Runnable interface, 774–775Runnable object, 774Running state, threads, 803Runtime errors, 57–58, 60, 578

finding/correcting, 58reasons for, 578

Runtime exceptions, 581RuntimeException, 581, 596

examples of subclasses of, 582

SSales amount, finding (example), 109–110SalesTax.java, 41Save file dialog, 994Scanner class, 52–53, 262, 286, 288–289, 292, 579

console input using, 52methods, 52–53reading data using, 287–289and whitespace, 288

Scientific notation, literals, 37scope attribute, 1221Scope of a local variable, 141–142Scope of variables, 141–142, 235Scripting constructs, 1211, 1211–1213

syntax, 1237–1238Scripting constructs, JSP, 1211–1213Scripting elements, JSP, 1211Scriptlets, 1211, 1213Scroll bars, 515–518

JScrollBar, 515–518ScrollBarDemo.java, 517–518

Scrollable and updateable result set, 1135–1145ScrollBarDemo.java, 517–518ScrollMap.java, 945–947ScrollUpdateRowSet.java, 1148–1149search() method, Stack class, 730Searching, defined, 185<select> … </select> tags, 1172selectedFile property, JFileChooser, 995selectedFiles property, JFileChooser, 995Selection sort, 642Selection sort algorithm, 744–745Selection sort, analyzing, 745–746Selection statements, 67–94selectionMode property, 1026selectionModel property, 1026SelectionSort.java, 188–189, 188–190, 745

Self-Test Web site, 15Semaphores, 801–802

New Account Inner Class, 802Semaphore class, 802

Semicolon, 21send(packet) method, DatagramSocket

class, 851Sentinel value, 99–100SentinelValue.java, 99–100Sequence diagrams, 390–391Sequential forward reading, 1135Serializable interface, 619–620

deserialization, 619duplicate objects, 619and JavaBeans, 898as marker interface, 619–620nonserializable fields, 619NotSerializableException, 619object serialization, 619, 630transient keyword, 619

Serializable, use of term, 618Serialization, 619Serializing arrays, 620

TestObjectStreamForArray.java, 620Server implementation, RMI, 1244Server object interface, RMI, 1244Server object, RMI, 1244Server, RMI, 1244Server skeleton, RMI, 1244Server sockets, 816–817Server stub, RMI, 1244Server.java, 819–820service method, Servlet interface, 1165Servlet API, 1164–1168

GenericServlet class, 1166HttpServlet class, 1166HttpServletRequest interface, 1167HttpServletResponse interface, 1168Servlet interface, 1165ServletConfig interface, 1166ServletRequest interface, 1167ServletResponse interface, 1168session tracking using, 1190–1195

Servlet container, 1160Servlet engine, 1160, 1163, 1168–1169Servlet interface, destroy method, 1165Servlet server, 1160servlet-api.jar, 1161ServletConfig interface, 1166

UML class diagram, 1167ServletRequest interface, 1166–1167

UML class diagram, 1167ServletResponse interface, 1168

UML class diagram, 1168Servlets, 15, 17, 1157–1208, 1210–1213

benefits inherent in, 1160Common Gateway Interface (CGI), 1158–1160compared to applets, 1160, 1168compiling, 1161–1162connecting to a database from, 1176creating, 1160–1170, 1168–1170CurrentTime.java, 1169–1170database programming in, 1176–1180

SimpleRegistration.java, 1178–1180defined, 1158FirstServlet.java, 1161GET and POST methods, 1159–1160getWriter method, 1170mapping to a URL, 1162–1163running, 1164sending images from, 1195–1200

ImageContent.java, 1195–1196ImageContentWithDrawing.java,

1197–1199

MixedContent.java, 1199–1200sending image from files, 1195–1196sending images and text together, 1199–1200sending images from the Image object,

1196–1199session tracking, 1180–1195setContentType method, 1170web.xml, 1162

Session, defined, 1180session attribute, page directive, 1216Session scope, 1232Session tracking, 1180–1195

defined, 1180using cookies, 1185–1190

RegistrationWithCookie.java, 1186–1189using hidden values, 1180–1185

Registration.html, 1182Registration.java, 1182–1185

using the Servlet API, 1190–1195session value, scope attribute, 1220session variable, JSP, 1213Set, 714Set interface, 716–721

defined, 716and duplicate elements, 716HashSet class, 716–718LinkedHashSet class, 718–719TreeSet class, 717, 719–721UML class diagram, 717

set method, 378setAccelerator method, 970setAttribute method, 1194, 1201setAutoCommit(false) method, 1110setBackground method, Component class, 446setBorder method, 959setCharAt method, 274setColor method:

FigurePanel class, 434Graphics class, 446

setColumns method, 412setContentPane() method, 919setContentType method, 1170setCorner() method, JScrollPane, 944setData method, 850setDefaultCloseOperation, 248setDelay method, 482, 556setFont method, 413

Component class, 413Component class, 413Graphics class, 446MessagePanel class, 500

setForeground method, Component class, 446setHgap method, 412setInverted method, 521setLayout method, 920, 931, 938setlength() method, StringBuffer class, 275setLength(int) method, StringBuffer class,

275setLocation method, 248setLookAndFeel method, 960setMaximumFractionDigits method, 876setMaxInactiveInterval method, 1191, 1194setMinimumFractionDigits method, 876setPriority method, Thread class, 779setRadius method, 224, 231setRows method, 412Sets, 28, 716–721

HashSet class, 716–717LinkedHashSet class, 718–719TestHashSet.java, 717–718TestLinkedHashSet.java, 718–719TestTreeSet.java, 720TreeSet class, 719–720

setSelectedItem method, 1036

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1297

Page 18: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1298 Index

setSelectionMode(int mode) method,TreeSelectionModel interface, 1078

setSize method, 248Setter, 230, 249setTime(Date) method, 376setTimeZone method, 864setTitle method, 248setVgap method, 412setVisible, 248Shallow copy, 355short, 32, 34, 89Short class, 356SHORT constant, DateFormat class, 865Short-circuit AND operator, 70, 89Short-circuit evaluation, 70–71Short-circuit OR operator, 70, 89Shortcut operators, 38–39shortValue() method, 356–357show method, 976Show Paths button, 1079ShowBorderLayout.java, 410–411ShowBoxLayout.java, 932–933ShowCardLayout.java, 922–924showConfirmDialog method, 984ShowCurrentTime.java, 51–52showDayNames method, 873showDays method, 873ShowDiagonalLayout.java, 942–943ShowGridBagLayout.java, 927–928ShowGridLayout.java, 409–410showHeader method, 873showInputDialog method, JOptionPane class,

42, 45, 52ShowInternalFrame.java, 999–1000ShowLayout.java, 949–951showMessageDialog method, 984

JOptionPane class, 22–23ShowNoLayout.java, 929–930showOptionDialog method, 986ShowOverLayLayout.java, 934–936showPopup method, 976showRootHandles property, 1070ShowSpringLayout.java, 937–938shuffle() method, and lists, 728shutdown command, Tomcat, 1163Sierpinski triangle:

creation of, 646defined, 646SierpinskiTriangle.java, 647–648

SierpinskiTriangle.java, 647–648SierpinskiTrianglePanel, 649signal() method, 793signalAll() method, 793Silicon semiconductor chips, 5Simple if statements, 73–74Simple math learning tool (example), 72Simple programs, writing, 17–18, 28–30SimpleDateFormat class, 865–866SimpleEventDemoAnonymousInnerClass.java,

472SimpleEventDemoInnerClass.java, 470–471SimpleEventdemo.java, 464SimpleJDBC.java, 1110SimpleRegistration.html, 1177–1178SimpleRegistration.java, 1178–1180SimpleRowSet.java, 1146SimpleSpinner.java, 1018SimpleTreeDemo.java, 1070–1072Single inheritance, 342Single precision, 34Single selection, 1078Single selection mode, JList, 512SINGLE_INTERVAL SELECTION value:

selectionMode property, 1026selectionModel property, 1026

SINGLE_SELECTION value:selectionMode property, 1026selectionModel property, 1026

Single-interval mode, JList, 512SingleThreadModel interface, 1216Sinking sort, defined, 747SixFlags.java, 453–454size attribute:

<input> tag, 1172<select> … </select> tags, 1172

size method:AbstractSet class, 716Collection interface, 715Collection interface, 715Map interface, 733

sleep(long) method, Thread class, 778Sliders, 518–521

JSlider, 518–521SliderBarDemo.java, 520–521

Socket-based communication, 816Socket-level programming., RMI vs., 1252Sockets, 816, 818

data transmission through, 818SoftBevelBorder class, 952–953Software, 6, 7, 11

application, 10defined, 4

Software development process, 372–374deployment, 373implementation, 372maintenance, 373requirements specification, 372system analysis, 372system design, 372testing, 372

sort method, 192Sorted tuples, displaying, 1104–1105SortedMap interface, 733–734Sorting, reasons for studying, 744Sorting algorithms, 2, 744Sorting arrays, 188–191

insertion sort, 190–191selection sort, 188–190

SortLargeFile.java, 763–765Source component, 465Source components, 900–901

custom, creating, 902–906Source directory path, 156Source object, 465, 486Source objects, 363, 900Source program, 9Spacing, 56Speed, CPU, 5Spinner editors, 1021–1022Spinner models and editors, 1016–1017

AbstractSpinnerModel, 1018–1019SimpleSpinner.java, 1018SpinnerModelEditorDemo.java, 1022–1024using (example), 1022–1024

SpinnerDateModel, 1020–1021UML class diagram, 1021

SpinnerListModel, 1018–1019SpinnerModel interface, 1017

UML class diagram, 1017SpinnerNumberModel, 1020

UML class diagram, 1020split method, 283Spring class, 936Spring, defined, 936SpringLayout manager, 936–938SpringLayout manager, 936–938SpringLayout manager:

creating, 936defined, 936ShowSpringLayout.java, 937–938

SQL, See Structured Query Language (SQL)SQLClient.java, 1126–1130sqrt method, 144src attribute, <img> tag, 1195Stack class, 319–320, 729–730

defined, 730UML class diagram, 730

Stack trace, 579StackOfIntegers class, 245–247, 246–247

implementation, 246–247Stacks, 28, 133, 159, 660, 675–677

composition, 675defined, 245, 675inheritance, 675insertion and deletion operations, 675

Standard output object, 22start method, Applet class, 537, 565Start tag, HTML, 539startup command, Tomcat, 1163Starvation, 779State, 214, 391stateChanged method, ChangeListener

interface, 519Statechart diagrams, 391–392Statement interface:

addBatch method, 1131, 1153executeQuery method, 1136

Statement labels, and breaking with labels, 115–116Statements, Java, 21States, threads, 803–804Static constants, 224–228Static import, 227Static inner class, 470static (keyword), 220Static methods, 23, 224, 224–228

hiding, 325–327static (modifier), 21Static variables, 224–228

defined, 224Static web contents, 1158–1168Statics methods:

for collections, 726–729for lists, 726–729

Stepwise refinement, defined, 147StillClock class, 447–451, 484

angle for the hour hand, 448DisplayClock.java, 447–448implementation, 449–450position of the minute hand, 448as reusable class, 451StillClock.java, 449–450UML class diagram, 447

stop method, Applet class, 537, 565Stopping condition, 640Storage devices, 4, 6, 11

CDs and DVDs, 4, 6disks, 6tapes, 4, 6USB flash drives, 6

StoreAndRetrieveImage.java, 1151–1153StoreData.java, 1228–1229StoreStudent.jsp, 1231–1232strBuf, 274Stream sockets, 816Streams, closing, 610String class, 262–270, 291, 321, 390

constructors, 262–263encapsulating string, 266equalsignorecase method, 265methods, 262regionmatches method, 265substring method, 267, 292

String concatenation operator, 30String literal, 41, 266String object, 263, 270

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1298

Page 19: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1299

String representation, 311String type, 44–45String value, 262String variable, 262StringBuffer class, 262, 273–277, 292, 321

capacity() method, 275charAt(int) method, 275length() method, 275setlength() method, 275toString() method, 275

StringBuilder class, 262, 273–274, 292append method, 274delete methods, 274insert method, 274

StringIndexOutOfBoundsException, 266, 578Strings:

comparisons, 264–265concatenation, 266constructing, 262conversions, 267conversions between arrays and, 268–269converting characters and numeric values to,

269–270converting to numbers, 46counting each letter in, 271–272defined, 262drawing, 431–432formatting, 84–86immutable, 263–264interned, 263–264length, 265–266, 275matching, 280replacing, 282–283splitting, 282–283string index range, 266substrings:

finding in, 267–268obtaining, 267

StringTokenizer class, 280Strong is-a relationship, 342, 376, 390Structure, relational database systems, 1094Structured Query Language (SQL), 1098–1106

arithmetic operators, 1104between-and operator, 1102–1103Boolean operators, 1102column alias, 1103comparison operators, 1102defined, 1098deleting records, 1101distinct keyword, 1104inserting data, 1101is null operator, 1102–1103keywords, 1098like operator, 1102–1103naming conventions, 1098order by clause, 1105PreparedStatement interface, 1113–1116queries, 1101–1102tables:

creating/dropping, 1098joining, 1105–1106

tuples:distinct, displaying, 1104sorted, displaying, 1104–1105

universal SQL client, 1126–1130updating data, 1101using on a relational database, 1099–1100

Strut, 931Stub, 149Student class, 232–233Student registration:

GetRegistrationData.jsp, 1231StoreData.java, 1228–1229StoreStudent.jsp, 1231–1232

Student scores, computing (example), 200–201

Student_Registration_Form.html, 1171Student3TierImpl.java, 1253–1255StudentClient.java, 830–833Student.java, 829–830, 1229–1230StudentServerInterfaceClient.java, 1250–1251StudentServerInterface.java, 1248, 1248–1249StudentServer.java, 833–834Subclasses, 302–306, 331

method overriding, 309Subinterfaces, 341Submenu items, creating, 969Subproblems, 147–149substring method, 292

String class, 267Substrings:

finding in strings, 267–268obtaining, 267

Subtraction ( ) operator, 35SubtractionTutor.java, 81, 97–98SubtractionTutorLoop.java, 97–98Subtrees, 1069Subtype, 302Subwindows, 521Sun Java Web site, 16Sun Microsystems, 16super (keyword), 307, 332Superclasses, 302–306, 331

calling methods, 308–309constructor chaining, 307–308constructors, calling, 307private data fields in, 309

super.clone() method, 356Superkey, 1096super.paintComponent(g), 430Supertype, 302Supplementary characters, 42Supplementary Unicode, 42, 607Supplier, 375swap method, 135–136Swing, AWT vs., 401Swing borders, 952–959

Abstract Border class, 952BevelBorder class, 952–953BorderDemo.java, 956–957CompoundBorder class, 952–953defined, 952EmptyBorder class, 952–953EtchedBorder class, 952–953javax.swing.BorderFactory class, 954LineBorder class, 952–953MatteBorder class, 952–953, 959SoftBevelBorder class, 952–953TitledBorder class, 952, 954, 959

Swing components:defined, 401model properties, 1016prefix J, 401simple, lack of models for, 1016

Swing container structures, 918–920Swing GUI component:

defined, 405, 1015TestSwingCommonFeatures.java, 416–417

Swing user interface components, implementationof, 1008

SwingConstants interface, 495switch statements, 81–83, 89

rules for, 82–83Sybase, 1099Synchronization wrappers, synchronizing

statements, 789–790Synchronized block, 790Synchronized collections, 804–805

Collections class, 804defined, 804synchronization wrappers, 804–805

synchronized keyword, 789–790Syntax errors, 57, 60, 578

finding/correcting, 58Syntax rules, Java, 18System analysis, 372System design, 372System errors, 581System.currentTimeMillis method, 51System.in, 52System.out, 52System.out.print method, 147System.out.println method, 17–18, 21–23,

29, 52

TTable data model, 1051Table model, JTable, 1046Table model events, 1065–1068

TableEventsDemo.java, 1066–1068Table renderers and editors, 1060–1062

custom, 1062–1065TableCellEditor interface, 1046TableCellRendererEditorDemo.java,

1061–1062TableColumn class, 1053–1054

UML class diagram, 1054TableColumnModel interface, 1053

methods, 1054UML class diagram, 1053

TableEditor.java, 1138–1143TableEventsDemo.java, 1066–1068Table.jsp, 1236TableModel interface, 1051–1053

UML class diagram, 1052TableModelDemo.java, 1056–1060TableModelEvents, 1051TablePropertiesDemo.java, 1048–1050Tables:

joining, 1105–1106relational database systems, 1095

tablib directive, 1216Tag names, HTML, 539Tags, HTML, 539tailMap() method, SortedMap interface, 734Tape drives, 6Tasks:

creating, 774–777defined, 774

TaskThreadDemo.java, 776–777Tax computation (example), 78–80, 139–141

with methods, 139–141temp.dat, 610Temp.txt, appending to text file, 61110BaseT, 7Ternary operator, 84TestActionEvent.java, 473TestArrayAndLinkedList.java, 725–726TestArray.java, 174–175TestArrayList.java, 317–318TestArrayListNew.java, 704TestBeanScope.jsp, 1221TestBinaryTree.java, 682–683TestBoolean.java, 70TestBreak.java, 114TestButtonIcons.java, 493–494TestCenterMessage.java, 441–442TestCircle1.java, 218, 218–219TestCircle2.java, 226TestCircle3.java, 231–232TestCircleRectangle.java, 306TestCircleWithException.java, 588TestColorDialog.java, 991–992TestContinue.java, 114–115TestCourse.java, 244

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1299

Page 20: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

1300 Index

TestCourseWithEnrollmentEvent.java, 910–911TestDatabaseMetaData.java, 1116–1117TestDataStream.java, 613TestDiagonalLayout class, 943TestDo.java, 101TestException.java, 586–587TestFigurePanel.java, 433TestFileClass.java, 285–286TestFileStream.java, 610TestFormatClass.java, 157–158TestFrame.java, 247–248TestGeometricObject.java, 345TestGetGraphics, 427TestGetGraphics.java, 428–429TestHashSet.java, 717–718TestHeap.java, 687–688TestImageIcon.java, 418–419Testing, 372TestIntegerMatrix.java, 709TestLinkedHashSet.java, 718–719TestList.java, 667–668TestLoanClass.java, 240–241TestMap.java, 735–736TestMax.java, 132TestMessagePanel.java, 442–443TestMethodOverloading.java, 137–138TestMultiplicationTable.java, 106TestObjectInputStream.java, 618TestObjectOutputStreamforArray.java, 620TestObjectOutputStream.java, 617–618TestObjectStreamForArray.java, 620TestPaintComponent.java, 429–430TestPanelDrawing.java, 430–431TestPanels.java, 414–415TestPassArray.java, 180–181TestPassByValue.java, 136–137TestPassObject.java, 233–234TestPolymorphismCasting.java, 315TestPriorityQueue.java, 688–689TestQueue.java, 731–732TestRandomAccessFile.java, 622–623TestRandomCharacter.java, 146TestRationalClass.java, 384TestRationalMatrix.java, 709–710TestResultSetMetaData.java, 1118–1119TestRowSetEvent.java, 1149–1150TestScanner.java, 53TestSourceListener.java, 901–902TestStackOfIntegers.java, 246TestStackQueue.java, 676–677TestSum.java, 106–107TestSwingCommonFeatures.java, 416–417TestTableColumnModel.java, 1053–1054TestTableEditor.java, 1136, 1137–1138TestTable.java, 1047–1048TestTableModel.java, 1051–1052TestTreeModel.java, 1073–1074TestTreePath.java, 1079–1080TestTreeSet.java, 720TestTreeSetWithComparator.java, 722–723TestVoidMethod.java, 134TestWindowEvent.java, 474–476Text areas, 506–509

TextAreaDemo.java, 507–508Text editors, using to create/edit Java source code

files, 17Text fields, 504–506

JPasswordField, 506JTextComponent, 504JTextField, 504TextFieldDemo.java, 504–505

Text files, 606text input type, 1172Text I/O, 286–289

binary I/O vs., 606–608

classes, 606efficiency of, 606PrintWriter class, writing data using,

286–287, 606Scanner class, reading data using, 287–289simplifying, 289

<textarea> … </textarea> tags, 1172TextEditor.java, 995–998TextPad Editor, 17this (keyword), 236–237Thread class, 777–779

deprecated (outdated) methods, 777InterruptedException, 778join() method, 779separating task from thread, 777setPriority method, 779sleep(long) method, 778UML class diagram, 777yield() method, 777

ThreadCooperation.java, 794–795Threads:

concept of, 774cooperation among, 792–796

example, 793ThreadCooperation.java, 794–795

creating, 774–777defined, 774finished, 804starting, 775states, 803, 803–804synchronization, 787–796

AccountWithoutSync.java, 787–789synchronized block, 790synchronized keyword, 789synchronizing statements, 789–790using locks, 790–796

TaskThreadDemo.java, 776–777thread pools, 785–786time-sharing, 775

Thread-safe, use of term, 789Three-tier applications:

developing using RMI, 1253–1255RegisterStudent3TierServer.java, 1255Student3TierImpl.java, 1253–1255

throw (keyword), 587Throwable class, 580

methods in, 580throwfor method, Scanner class, 579Throwing an exception, 587–589throws (keyword), 587TicTacToe game, 550–554

incremental development and testing, 554TicTacToeClient class, 845–849TicTacToeClient.java, 845–849TicTacToeClientRMI.java, 1261–1264TicTacToeConstants interface, 839–840TicTacToeConstants.java, 839–840TicTacToeImpl.java, 1258–1260TicTacToeInterface.java, 1256–1257TicTacToeServer class, 840–845TicTacToeServer.java, 840–845TimeBean.java, 1226TimeForm.java, 1175–1176Timer class:

animation using, 482–485UML class diagram, 482

Timer object, 482Time-sharing, 775timeStyle method, 865TimeZone class, 864–865TimeZone class, 864–865, 1228

getAvailableIDs() method, 864title property, JFrame, 919<title> tag, HTML, 539TitledBorder class, 952, 954, 959

toArray() method, Collection interface, 716toCharArray method, 268Toggle button, 498toLowerCase method, 267, 273Tomcat, 1159, 1210

context root directory, creating, 1161and port 8080, 1163restarting, 1170servlet engine, starting, 1163shutting down, 1163starting/stopping, 1163–1164tutorial, 1159webapps directory, 1161

Tool tip, 415ToolBarDemo.java, 977, 977–978Toolbars:

defined, 976floatable buttons, 977

Top-down design, 148–149Top-down implementation, 149–151toString() method, 222, 256, 302–306,

309–313, 320, 322, 332, 333–334, 339,586, 589

GeometricObject class, 309Object class, 310–311signature of, 310StringBuffer class, 275toString() method, 275

TotalArea.java, 237–238totalNumberOfDays, 148, 149, 151TotalScore.java, 200–201toUpperCase method, 267Tower of Hanoi problem, 643–646

goal of, 645TowersOfHanoi.java, 645–646

Towers of Hanoi problem, 746TowersofHanoi.java, 645–646TowersOfHanoi.java, 746transient keyword, 619Transistors, 5Transition, 391Transmission Control Protocol (TCP), 816Tree events, 1085Tree model, creating, 1077Tree node rendering and editing, 1084–1085Tree nodes, 1078Tree selection modes, 1078Tree traversal, 679, 679–680TreeCellRenderer interface, 1084TreeExpansionEvent, 1085TreeExpansionListener, 1085TreeMap class, 734–735TreeModel interface, 1069, 1073–1074

TestTreeModel.java, 1073–1074UML class diagram, 1073

TreeNode interface, 1069UML class diagram, 1076

TreeNode root, 1077TreeNodeDemo.java, 1074–1075TreePath, 1069, 1077–1080TreePath:

defined, 1069obtaining tree paths, 1078TestTreePath.java, 1079–1080UML class diagram, 1077

Trees:data representation of, 1069, 1085modifying, 1077, 1080–1083ModifyTree.java, 1081–1083nonleaf node, 1069subtrees, 1069tree node rendering and editing, 1084–1085

TreeSelectionEvent, 1085TreeSelectionListener interface, 1085TreeSelectionModel interface, 1078

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1300

Page 21: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

Index 1301

bypassing, 1078setSelectionMode(int mode) method, 1078UML class diagram, 1078

TreeSet class, 716, 719–721, 726SortedSet interface, 719TestTreeSet.java, 720UML class diagram, 717

Trigonometric methods, 142Math class, 142

trim() method, 267trimtosize() method, ArrayList class, 724–725trimToSize() method, ArrayList class, 724–725Trusted applets, 545try (keyword), 580try-catch block, 355, 579, 778Tuples, 1095

distinct, displaying, 1104–1105sorted, displaying, 1104–1105

TwoButtons.java, 291Two-dimensional arrays, 192–199

creating, 193–194declaring variables of, 193–194multiple-choice test, grading (example),

196–197obtaining the lengths of, 194processing, 195–196ragged arrays, 194–195

type attribute, <input> tag, 1172Type casting, 40TYPE_FORWARD_ONLY constant, 1135TYPE_SCROLL_INSENSITIVE constant, 1135TYPE_SCROLL_SENSITIVE constant, 1135

UUDP (User Datagram Protocol), 816, 850UML class diagram, 215UML (Unified Modeling Language), 215Unary operator, 36Unbounded wildcards, 701Unboxing, 362–363Unchecked exceptions, 582Unconditional AND operator, 70, 89Unconditional Boolean operators:

conditional Boolean operators vs., 70–71Unconditional OR operator, 70, 89Unicode, 42, 68, 862–864, 890

lowercase/uppercase letters, 44Unicode character set, 612Unified Modeling Language (UML), 372Universal SQL client, 1126–1130

SQLClient.java, 1126–1130UNIX, classpath variable, 155Unix epoch, 51Unsafe raw types, avoiding, 703–705

GenericSortNew.java, 705TestArrayListNew.java, 704

UnsupportedLookAndFeelException, 960Upcasting, 313–314updateRow() method, 1136updateString method, 888URL:

accessing by class code, 558defined, 558query string, 1159

URL class, 557–560USB flash drives, 6UseCustomFrame.java, 330–331UseFlowLayout.java, 290–291User Datagram Protocol (UDP), 816User interface (UI), 491–533

buttons, 492–498check boxes, 498–500combo boxes, 509–512labels, 503–504

lists, 512–515multiple windows, creating, 521–525radio buttons, 501–503scroll bars, 515–518sliders, 518–521text areas, 506–509text fields, 504–506

UTF-8 scheme, 612format, advantage of, 612–613

Vvalidate() method, 412, 939value attribute, <input> tag, 1172valueChanged method, TreeSelectionListener

interface, 1085valueOf method, 269

operator, 39operator, 39

VarargsDemo.java, 185Variable declaration, 31, 33Variable-length argument lists, 185Variables, 28–29, 31–32

classes, 235declaring, 28declaring and initializing, in one step, 32–33defined, 29as expressions, 32instance, 217, 224naming, 55of primitive types and reference types,

differences between, 221–222scope of, 141–142static, 224, 224–228uses of, 31–32

Vector class, 318, 729–730defined, 729UML class diagram, 730

Vertical alignment, buttons, 494Vertical layout, lists, 1026Vertical text position, 495Vertical wrap layout, lists, 1026vgap property, BorderLayout manager, 412ViewController, 1014Viewport, 943–944ViewRemoteFile.java, 835–836VirtualMachineError subclass, Error class, 581Visibility modifiers, 228–229, 320–321visibleRowCount property, 1026Visual Basic, 8–9void keyword, and constructors, 216void method, 130

example, 134–135vsbPolicy parameter, JScrollPane, 944vspace attribute, <applet> tag, HTML, 540

WWAR files, 1163Weak is-a relationship, 376, 390

represented using interfaces, 376Web archive file (WAR), 1163Web browsers, 4, 10, 14, 24–25Web development tools, 1163Web pages:

dynamic web contents, 17, 1158–1159, 1210static web contents, 1158–1168

Web servers, retrieving files from, 834–836WebBrowser.java, 837–838web.xml, 1162, 1162–1163WelcomeApplet.html, 538–541WelcomeInMessageDialogBox.java, 22–23while loop, 96–100, 118Whitespace, 54, 280

and Scanner class, 288

var��var��

Widening a type, 40, 60Wildcards, 701–703

bounded, 701lower bound, 701unbounded, 701WildCardDemo1.java, 701WildCardDemo2.java, 702WildCardDemo3.java, 702

Window class, 466Window events, 484

handling, 474–475TestWindowEvent.java, 474–476

windowActivated handler, 476WindowAdapter, 476WindowEvent, 466, 467WindowListener interface, 467

WindowAdapter, 476Windows:

creating, 247–248popup menus in, 1001

Windows 98, classpath variable, 155Windows Calculator, 12Windows, creating, 247–248Windows NT/2000/XP, classpath variable, 155Windows operating system, 9WinZip, 563Word characters, 280Word processors, 4, 10, 24Words, occurrences of, 736–737

CountOccurrenceOfWords.java, 736–737World Wide Web, defined, 14WorldClockApp.java, 870WorldClockControl.java, 868–869WorldClock.java, 867–868Worst-case analysis, 745, 766Wrapper class types, automatic conversion

between primitive types and, 362–363

Wrapper classes, 270, 358immutable instances of, 358and no-arg constructor, 358

wrapStyleWord property, 509writeBoolean method, 621writeBytes method, 612writeChar method, 621writeChars method, 612WriteData.java, 286–287writeDouble method, 621writeInt method, 621Write-only property, 900Write-only streams, 621writeUTF method, 621writeUTF(String s) method, 612

X(postdecrement operator), 39(predecrement operator), 39(postincrement operator), 39

xCoordinate, 442XEvent, 467XListener interface, 467xpoints data field, 438

YyCoordinate, 442yield() method, 778

Thread class, 778ypoints data field, 438

Z0-based indices, 171Zeros and ones, 5, 11

x����xx��

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1301

Page 22: LIANMINDv2.QXD 5/25/06 4:37 AM Page 1281 INDEXptgmedia.pearsoncmg.com/images/9780132221580/sample... · 2009-06-09 · bubble sort algorithm, 747–748 common growth functions: change

LIANMINDv2.QXD 5/25/06 4:37 AM Page 1302


Recommended