- Page 2:
ONLINE ACCESS Thank you for purchas
- Page 6:
This page intentionally left blank
- Page 10:
Editorial Director: Marcia Horton E
- Page 14:
This page intentionally left blank
- Page 18:
viii Preface complete revision new
- Page 22:
x Preface Organization of the Book
- Page 26:
xii Preface ■ ■ Instructors can
- Page 30:
xiv Preface Tront (Simon Fraser Uni
- Page 34:
CONTENTS Chapter 1 Introduction to
- Page 38:
xviii Contents 5.6 Modularizing Cod
- Page 42:
xx Contents 11.11 The ArrayList Cla
- Page 46:
xxii Contents 17.7 Sliders 657 17.8
- Page 50:
VideoNote VideoNotes Locations of V
- Page 54:
xxvi VideoNotes Chapter 19 Chapter
- Page 58:
2 Chapter 1 Introduction to Compute
- Page 62:
4 Chapter 1 Introduction to Compute
- Page 66:
6 Chapter 1 Introduction to Compute
- Page 70:
8 Chapter 1 Introduction to Compute
- Page 74:
10 Chapter 1 Introduction to Comput
- Page 78:
12 Chapter 1 Introduction to Comput
- Page 82:
14 Chapter 1 Introduction to Comput
- Page 86:
16 Chapter 1 Introduction to Comput
- Page 90:
18 Chapter 1 Introduction to Comput
- Page 94:
20 Chapter 1 Introduction to Comput
- Page 98:
22 Chapter 1 Introduction to Comput
- Page 102:
24 Chapter 1 Introduction to Comput
- Page 106:
26 Chapter 1 Introduction to Comput
- Page 110:
28 Chapter 1 Introduction to Comput
- Page 114:
30 Chapter 1 Introduction to Comput
- Page 118:
32 Chapter 1 Introduction to Comput
- Page 122:
34 Chapter 2 Elementary Programming
- Page 126:
36 Chapter 2 Elementary Programming
- Page 130:
38 Chapter 2 Elementary Programming
- Page 134:
40 Chapter 2 Elementary Programming
- Page 138:
42 Chapter 2 Elementary Programming
- Page 142:
44 Chapter 2 Elementary Programming
- Page 146:
46 Chapter 2 Elementary Programming
- Page 150:
48 Chapter 2 Elementary Programming
- Page 154:
50 Chapter 2 Elementary Programming
- Page 158:
52 Chapter 2 Elementary Programming
- Page 162:
54 Chapter 2 Elementary Programming
- Page 166:
56 Chapter 2 Elementary Programming
- Page 170:
58 Chapter 2 Elementary Programming
- Page 174:
60 Chapter 2 Elementary Programming
- Page 178:
62 Chapter 2 Elementary Programming
- Page 182:
64 Chapter 2 Elementary Programming
- Page 186:
66 Chapter 2 Elementary Programming
- Page 190:
68 Chapter 2 Elementary Programming
- Page 194:
70 Chapter 2 Elementary Programming
- Page 198:
72 Chapter 2 Elementary Programming
- Page 202:
74 Chapter 2 Elementary Programming
- Page 206:
76 Chapter 2 Elementary Programming
- Page 210:
78 Chapter 2 Elementary Programming
- Page 214:
80 Chapter 2 Elementary Programming
- Page 218:
82 Chapter 3 Selections problem sel
- Page 222:
84 Chapter 3 Selections ✓Point✓
- Page 226:
86 Chapter 3 Selections Enter an in
- Page 230:
88 Chapter 3 Selections in Set4? in
- Page 234:
90 Chapter 3 Selections Here is the
- Page 238:
92 Chapter 3 Selections score >= 90
- Page 242:
94 Chapter 3 Selections Common Erro
- Page 246:
96 Chapter 3 Selections VideoNote P
- Page 250:
98 Chapter 3 Selections LISTING 3.5
- Page 254:
100 Chapter 3 Selections input stat
- Page 258:
102 Chapter 3 Selections to create
- Page 262:
104 Chapter 3 Selections incompatib
- Page 266:
106 Chapter 3 Selections input leap
- Page 270:
108 Chapter 3 Selections Key Point
- Page 274:
110 Chapter 3 Selections Now let us
- Page 278:
112 Chapter 3 Selections The result
- Page 282:
114 Chapter 3 Selections Here is an
- Page 286:
116 Chapter 3 Selections operator p
- Page 290:
118 Chapter 3 Selections set3 set4
- Page 294:
120 Chapter 3 Selections ■ Settin
- Page 298:
122 Chapter 3 Selections Note that
- Page 302:
124 Chapter 3 Selections example, i
- Page 306:
126 Chapter 3 Selections y-axis (9,
- Page 310:
128 Chapter 3 Selections Enter a po
- Page 314:
130 Chapter 3 Selections Enter the
- Page 318:
This page intentionally left blank
- Page 322:
134 Chapter 4 Loops problem Key Poi
- Page 326:
136 Chapter 4 Loops This loop is in
- Page 330:
138 Chapter 4 Loops too low? 20 Sys
- Page 334:
140 Chapter 4 Loops get start time
- Page 338:
142 Chapter 4 Loops loop end of loo
- Page 342:
144 Chapter 4 Loops 4.4 Suppose the
- Page 346:
146 Chapter 4 Loops ✓Point✓ Che
- Page 350:
148 Chapter 4 Loops initial-action
- Page 354:
150 Chapter 4 Loops pretest loop po
- Page 358:
152 Chapter 4 Loops nested loop tab
- Page 362:
154 Chapter 4 Loops VideoNote Minim
- Page 366:
156 Chapter 4 Loops input input gcd
- Page 370:
158 Chapter 4 Loops 4.8.3 Case Stud
- Page 374:
160 Chapter 4 Loops continue LISTIN
- Page 378:
162 Chapter 4 Loops 4.24 Rewrite th
- Page 382:
164 Chapter 4 Loops The first 50 pr
- Page 386:
166 Chapter 4 Loops CHAPTER SUMMARY
- Page 390:
168 Chapter 4 Loops 4.6 (Conversion
- Page 394:
170 Chapter 4 Loops VideoNote Displ
- Page 398:
172 Chapter 4 Loops *4.30 (Financia
- Page 402:
174 Chapter 4 Loops *4.42 (Financia
- Page 406:
This page intentionally left blank
- Page 410:
178 Chapter 5 Methods problem why m
- Page 414:
180 Chapter 5 Methods define vs. de
- Page 418:
182 Chapter 5 Methods public static
- Page 422:
184 Chapter 5 Methods getGrade meth
- Page 426:
186 Chapter 5 Methods Key Point par
- Page 430:
188 Chapter 5 Methods The values of
- Page 434:
190 Chapter 5 Methods invoke gcd co
- Page 438:
192 Chapter 5 Methods For example,
- Page 442:
194 Chapter 5 Methods method overlo
- Page 446:
196 Chapter 5 Methods } public stat
- Page 450:
198 Chapter 5 Methods /** Convert t
- Page 454:
200 Chapter 5 Methods Math.abs(-2)
- Page 458:
202 Chapter 5 Methods Hence, a rand
- Page 462:
204 Chapter 5 Methods Enter full ye
- Page 466:
206 Chapter 5 Methods printCalendar
- Page 470:
208 Chapter 5 Methods printMonth pr
- Page 474:
210 Chapter 5 Methods isLeapYear 11
- Page 478:
212 Chapter 5 Methods PROGRAMMING E
- Page 482:
214 Chapter 5 Methods /** Convert f
- Page 486:
216 Chapter 5 Methods 5.18 (Use the
- Page 490:
218 Chapter 5 Methods Comprehensive
- Page 494:
220 Chapter 5 Methods 5. If the res
- Page 498:
222 Chapter 5 Methods Write a test
- Page 502:
224 Chapter 6 Single-Dimensional Ar
- Page 506:
226 Chapter 6 Single-Dimensional Ar
- Page 510:
228 Chapter 6 Single-Dimensional Ar
- Page 514:
230 Chapter 6 Single-Dimensional Ar
- Page 518:
232 Chapter 6 Single-Dimensional Ar
- Page 522:
234 Chapter 6 Single-Dimensional Ar
- Page 526:
236 Chapter 6 Single-Dimensional Ar
- Page 530:
238 Chapter 6 Single-Dimensional Ar
- Page 534:
240 Chapter 6 Single-Dimensional Ar
- Page 538:
242 Chapter 6 Single-Dimensional Ar
- Page 542:
244 Chapter 6 Single-Dimensional Ar
- Page 546:
246 Chapter 6 Single-Dimensional Ar
- Page 550:
248 Chapter 6 Single-Dimensional Ar
- Page 554:
250 Chapter 6 Single-Dimensional Ar
- Page 558:
252 Chapter 6 Single-Dimensional Ar
- Page 562:
254 Chapter 6 Single-Dimensional Ar
- Page 566:
256 Chapter 6 Single-Dimensional Ar
- Page 570:
258 Chapter 6 Single-Dimensional Ar
- Page 574:
260 Chapter 6 Single-Dimensional Ar
- Page 578:
262 Chapter 6 Single-Dimensional Ar
- Page 582:
264 Chapter 7 Multidimensional Arra
- Page 586:
266 Chapter 7 Multidimensional Arra
- Page 590:
268 Chapter 7 Multidimensional Arra
- Page 594:
270 Chapter 7 Multidimensional Arra
- Page 598:
272 Chapter 7 Multidimensional Arra
- Page 602:
274 Chapter 7 Multidimensional Arra
- Page 606:
276 Chapter 7 Multidimensional Arra
- Page 610:
278 Chapter 7 Multidimensional Arra
- Page 614:
280 Chapter 7 Multidimensional Arra
- Page 618:
282 Chapter 7 Multidimensional Arra
- Page 622:
284 Chapter 7 Multidimensional Arra
- Page 626:
286 Chapter 7 Multidimensional Arra
- Page 630:
288 Chapter 7 Multidimensional Arra
- Page 634:
290 Chapter 7 Multidimensional Arra
- Page 638:
292 Chapter 7 Multidimensional Arra
- Page 642:
294 Chapter 7 Multidimensional Arra
- Page 646:
296 Chapter 8 Objects and Classes w
- Page 650:
298 Chapter 8 Objects and Classes U
- Page 654:
300 Chapter 8 Objects and Classes T
- Page 658:
302 Chapter 8 Objects and Classes s
- Page 662:
304 Chapter 8 Objects and Classes K
- Page 666:
306 Chapter 8 Objects and Classes }
- Page 670:
308 Chapter 8 Objects and Classes 1
- Page 674:
310 Chapter 8 Objects and Classes W
- Page 678:
312 Chapter 8 Objects and Classes c
- Page 682:
314 Chapter 8 Objects and Classes 2
- Page 686:
316 Chapter 8 Objects and Classes N
- Page 690:
318 Chapter 8 Objects and Classes u
- Page 694:
320 Chapter 8 Objects and Classes A
- Page 698:
322 Chapter 8 Objects and Classes S
- Page 702:
324 Chapter 8 Objects and Classes S
- Page 706:
326 Chapter 8 Objects and Classes 8
- Page 710:
328 Chapter 8 Objects and Classes 8
- Page 714:
330 Chapter 8 Objects and Classes T
- Page 718:
332 Chapter 8 Objects and Classes
- Page 722:
334 Chapter 8 Objects and Classes T
- Page 726:
336 Chapter 9 Strings Key Point Key
- Page 730:
338 Chapter 9 Strings java.lang.Str
- Page 734:
340 Chapter 9 Strings string index
- Page 738:
342 Chapter 9 Strings why regular e
- Page 742:
344 Chapter 9 Strings To convert an
- Page 746:
346 Chapter 9 Strings 9.5 Let s1 be
- Page 750:
348 Chapter 9 Strings low index hig
- Page 754:
350 Chapter 9 Strings hex char to d
- Page 758:
352 Chapter 9 Strings input string
- Page 762:
354 Chapter 9 Strings java.lang.Str
- Page 766:
356 Chapter 9 Strings the builder
- Page 770:
358 Chapter 9 Strings 9.20 Suppose
- Page 774:
360 Chapter 9 Strings Add Subtract
- Page 778:
362 Chapter 9 Strings 4. You can us
- Page 782:
364 Chapter 9 Strings Enter a strin
- Page 786:
366 Chapter 9 Strings **9.18 (Imple
- Page 790:
368 Chapter 9 Strings Enter a genom
- Page 794:
370 Chapter 10 Thinking in Objects
- Page 798:
372 Chapter 10 Thinking in Objects
- Page 802:
374 Chapter 10 Thinking in Objects
- Page 806:
376 Chapter 10 Thinking in Objects
- Page 810:
378 Chapter 10 Thinking in Objects
- Page 814:
380 Chapter 10 Thinking in Objects
- Page 818:
382 Chapter 10 Thinking in Objects
- Page 822:
384 Chapter 10 Thinking in Objects
- Page 826:
386 Chapter 10 Thinking in Objects
- Page 830:
388 Chapter 10 Thinking in Objects
- Page 834:
390 Chapter 10 Thinking in Objects
- Page 838:
392 Chapter 10 Thinking in Objects
- Page 842:
394 Chapter 10 Thinking in Objects
- Page 846:
396 Chapter 10 Thinking in Objects
- Page 850:
398 Chapter 10 Thinking in Objects
- Page 854:
400 Chapter 10 Thinking in Objects
- Page 858:
402 Chapter 10 Thinking in Objects
- Page 862:
404 Chapter 10 Thinking in Objects
- Page 866:
406 Chapter 10 Thinking in Objects
- Page 870:
408 Chapter 11 Inheritance and Poly
- Page 874:
410 Chapter 11 Inheritance and Poly
- Page 878:
412 Chapter 11 Inheritance and Poly
- Page 882:
414 Chapter 11 Inheritance and Poly
- Page 886:
416 Chapter 11 Inheritance and Poly
- Page 890:
418 Chapter 11 Inheritance and Poly
- Page 894:
420 Chapter 11 Inheritance and Poly
- Page 898:
422 Chapter 11 Inheritance and Poly
- Page 902:
424 Chapter 11 Inheritance and Poly
- Page 906:
426 Chapter 11 Inheritance and Poly
- Page 910:
428 Chapter 11 Inheritance and Poly
- Page 914:
430 Chapter 11 Inheritance and Poly
- Page 918:
432 Chapter 11 Inheritance and Poly
- Page 922:
434 Chapter 11 Inheritance and Poly
- Page 926:
436 Chapter 11 Inheritance and Poly
- Page 930:
438 Chapter 11 Inheritance and Poly
- Page 934:
440 Chapter 11 Inheritance and Poly
- Page 938:
442 Chapter 11 Inheritance and Poly
- Page 942:
444 Chapter 11 Inheritance and Poly
- Page 946:
446 Chapter 12 GUI Basics AWT Swing
- Page 950:
448 Chapter 12 GUI Basics TABLE 12.
- Page 954:
450 Chapter 12 GUI Basics Title bar
- Page 958:
452 Chapter 12 GUI Basics VideoNote
- Page 962:
454 Chapter 12 GUI Basics This code
- Page 966:
456 Chapter 12 GUI Basics because t
- Page 970:
458 Chapter 12 GUI Basics can then
- Page 974:
460 Chapter 12 GUI Basics 31 /** Ma
- Page 978:
462 Chapter 12 GUI Basics VideoNote
- Page 982:
464 Chapter 12 GUI Basics set foreg
- Page 986:
466 Chapter 12 GUI Basics An image
- Page 990:
468 Chapter 12 GUI Basics Component
- Page 994:
470 Chapter 12 GUI Basics horizonta
- Page 998:
472 Chapter 12 GUI Basics Here is a
- Page 1002:
474 Chapter 12 GUI Basics // Create
- Page 1006:
476 Chapter 12 GUI Basics 10. You c
- Page 1010:
478 Chapter 12 GUI Basics VideoNote
- Page 1014:
480 Chapter 13 Graphics Problem Key
- Page 1018:
482 Chapter 13 Graphics create a pa
- Page 1022:
484 Chapter 13 Graphics (x, y) (x,
- Page 1026:
486 Chapter 13 Graphics 19 frame.se
- Page 1030:
488 Chapter 13 Graphics The repaint
- Page 1034:
490 Chapter 13 Graphics negative de
- Page 1038:
492 Chapter 13 Graphics 2 6 (x, y)
- Page 1042:
494 Chapter 13 Graphics This method
- Page 1046:
496 Chapter 13 Graphics add message
- Page 1050:
498 Chapter 13 Graphics repaint pan
- Page 1054:
500 Chapter 13 Graphics 1 public cl
- Page 1058:
502 Chapter 13 Graphics The positio
- Page 1062:
504 Chapter 13 Graphics get current
- Page 1066:
506 Chapter 13 Graphics Key Point 1
- Page 1070:
508 Chapter 13 Graphics 37 38 /** R
- Page 1074:
510 Chapter 13 Graphics (a) (b) (c)
- Page 1078:
512 Chapter 13 Graphics Hint: The U
- Page 1082:
514 Chapter 13 Graphics 13.23 (Disp
- Page 1086:
516 Chapter 13 Graphics *13.32 (Geo
- Page 1090:
518 Chapter 14 Exception Handling a
- Page 1094:
520 Chapter 14 Exception Handling a
- Page 1098:
522 Chapter 14 Exception Handling a
- Page 1102:
524 Chapter 14 Exception Handling a
- Page 1106:
526 Chapter 14 Exception Handling a
- Page 1110:
528 Chapter 14 Exception Handling a
- Page 1114:
530 Chapter 14 Exception Handling a
- Page 1118:
532 Chapter 14 Exception Handling a
- Page 1122:
534 Chapter 14 Exception Handling a
- Page 1126:
536 Chapter 14 Exception Handling a
- Page 1130:
538 Chapter 14 Exception Handling a
- Page 1134:
540 Chapter 14 Exception Handling a
- Page 1138:
542 Chapter 14 Exception Handling a
- Page 1142:
544 Chapter 14 Exception Handling a
- Page 1146:
546 Chapter 14 Exception Handling a
- Page 1150:
548 Chapter 14 Exception Handling a
- Page 1154:
550 Chapter 14 Exception Handling a
- Page 1158:
552 Chapter 14 Exception Handling a
- Page 1162:
554 Chapter 14 Exception Handling a
- Page 1166:
556 Chapter 14 Exception Handling a
- Page 1170:
558 Chapter 14 Exception Handling a
- Page 1174:
560 Chapter 15 Abstract Classes and
- Page 1178:
562 Chapter 15 Abstract Classes and
- Page 1182:
564 Chapter 15 Abstract Classes and
- Page 1186:
566 Chapter 15 Abstract Classes and
- Page 1190:
568 Chapter 15 Abstract Classes and
- Page 1194:
570 Chapter 15 Abstract Classes and
- Page 1198:
572 Chapter 15 Abstract Classes and
- Page 1202:
574 Chapter 15 Abstract Classes and
- Page 1206:
576 Chapter 15 Abstract Classes and
- Page 1210:
578 Chapter 15 Abstract Classes and
- Page 1214:
580 Chapter 15 Abstract Classes and
- Page 1218:
582 Chapter 15 Abstract Classes and
- Page 1222:
584 Chapter 15 Abstract Classes and
- Page 1226:
586 Chapter 15 Abstract Classes and
- Page 1230:
588 Chapter 15 Abstract Classes and
- Page 1234:
590 Chapter 15 Abstract Classes and
- Page 1238:
592 Chapter 15 Abstract Classes and
- Page 1242:
594 Chapter 15 Abstract Classes and
- Page 1246:
596 Chapter 15 Abstract Classes and
- Page 1250:
This page intentionally left blank
- Page 1254:
600 Chapter 16 Event-Driven Program
- Page 1258:
602 Chapter 16 Event-Driven Program
- Page 1262:
604 Chapter 16 Event-Driven Program
- Page 1266:
606 Chapter 16 Event-Driven Program
- Page 1270:
608 Chapter 16 Event-Driven Program
- Page 1274:
610 Chapter 16 Event-Driven Program
- Page 1278:
612 Chapter 16 Event-Driven Program
- Page 1282:
614 Chapter 16 Event-Driven Program
- Page 1286:
616 Chapter 16 Event-Driven Program
- Page 1290:
618 Chapter 16 Event-Driven Program
- Page 1294:
620 Chapter 16 Event-Driven Program
- Page 1298:
622 Chapter 16 Event-Driven Program
- Page 1302:
624 Chapter 16 Event-Driven Program
- Page 1306:
626 Chapter 16 Event-Driven Program
- Page 1310:
628 Chapter 16 Event-Driven Program
- Page 1314:
630 Chapter 16 Event-Driven Program
- Page 1318:
632 Chapter 16 Event-Driven Program
- Page 1322:
634 Chapter 16 Event-Driven Program
- Page 1326:
636 Chapter 16 Event-Driven Program
- Page 1330:
638 Chapter 16 Event-Driven Program
- Page 1334:
640 Chapter 17 GUI Components Key P
- Page 1338:
642 Chapter 17 GUI Components regis
- Page 1342:
644 Chapter 17 GUI Components Key P
- Page 1346:
646 Chapter 17 GUI Components wrap
- Page 1350:
648 Chapter 17 GUI Components javax
- Page 1354:
650 Chapter 17 GUI Components liste
- Page 1358:
652 Chapter 17 GUI Components JList
- Page 1362:
654 Chapter 17 GUI Components By de
- Page 1366:
656 Chapter 17 GUI Components verti
- Page 1370:
658 Chapter 17 GUI Components javax
- Page 1374:
660 Chapter 17 GUI Components 64 do
- Page 1378:
662 Chapter 17 GUI Components creat
- Page 1382:
664 Chapter 17 GUI Components ✓Po
- Page 1386:
666 Chapter 17 GUI Components *17.6
- Page 1390:
668 Chapter 17 GUI Components Video
- Page 1394:
670 Chapter 17 GUI Components **17.
- Page 1398:
672 Chapter 18 Applets and Multimed
- Page 1402:
674 Chapter 18 Applets and Multimed
- Page 1406:
676 Chapter 18 Applets and Multimed
- Page 1410:
678 Chapter 18 Applets and Multimed
- Page 1414:
680 Chapter 18 Applets and Multimed
- Page 1418:
682 Chapter 18 Applets and Multimed
- Page 1422:
684 Chapter 18 Applets and Multimed
- Page 1426:
686 Chapter 18 Applets and Multimed
- Page 1430:
688 Chapter 18 Applets and Multimed
- Page 1434:
690 Chapter 18 Applets and Multimed
- Page 1438:
692 Chapter 18 Applets and Multimed
- Page 1442:
694 Chapter 18 Applets and Multimed
- Page 1446:
696 Chapter 18 Applets and Multimed
- Page 1450:
698 Chapter 18 Applets and Multimed
- Page 1454:
700 Chapter 18 Applets and Multimed
- Page 1458:
702 Chapter 18 Applets and Multimed
- Page 1462:
704 Chapter 18 Applets and Multimed
- Page 1466:
706 Chapter 18 Applets and Multimed
- Page 1470:
708 Chapter 18 Applets and Multimed
- Page 1474:
710 Chapter 19 Binary I/O text file
- Page 1478:
712 Chapter 19 Binary I/O hex) and
- Page 1482:
714 Chapter 19 Binary I/O java.io.I
- Page 1486:
716 Chapter 19 Binary I/O new Print
- Page 1490:
718 Chapter 19 Binary I/O The follo
- Page 1494:
720 Chapter 19 Binary I/O BufferedI
- Page 1498:
722 Chapter 19 Binary I/O public cl
- Page 1502:
724 Chapter 19 Binary I/O output st
- Page 1506:
726 Chapter 19 Binary I/O output 10
- Page 1510:
728 Chapter 19 Binary I/O number in
- Page 1514:
730 Chapter 19 Binary I/O «interfa
- Page 1518:
732 Chapter 19 Binary I/O A RandomA
- Page 1522:
734 Chapter 19 Binary I/O Section 1
- Page 1526:
736 Chapter 19 Binary I/O For a hin
- Page 1530:
738 Chapter 20 Recursion search wor
- Page 1534:
740 Chapter 20 Recursion factorial(
- Page 1538:
742 Chapter 20 Recursion The series
- Page 1542:
744 Chapter 20 Recursion Pedagogica
- Page 1546:
746 Chapter 20 Recursion 12 System.
- Page 1550:
748 Chapter 20 Recursion recursive
- Page 1554:
750 Chapter 20 Recursion getSize me
- Page 1558:
752 Chapter 20 Recursion n - 1 disk
- Page 1562:
754 Chapter 20 Recursion system use
- Page 1566:
756 Chapter 20 Recursion 20.20 ✓P
- Page 1570:
758 Chapter 20 Recursion performanc
- Page 1574:
760 Chapter 20 Recursion TEST QUEST
- Page 1578:
762 Chapter 20 Recursion *20.16 (Fi
- Page 1582:
764 Chapter 20 Recursion (a) Correc
- Page 1586:
766 Chapter 20 Recursion FIGURE 20.
- Page 1590:
This page intentionally left blank
- Page 1594:
This page intentionally left blank
- Page 1598:
APPENDIX B The ASCII Character Set
- Page 1602:
APPENDIX C Operator Precedence Char
- Page 1606:
APPENDIX D Java Modifiers Modifiers
- Page 1610:
APPENDIX E Special Floating-Point V
- Page 1614:
780 Appendix F binary to decimal F.
- Page 1618:
782 Appendix F TABLE F.1 Converting
- Page 1622:
This page intentionally left blank
- Page 1626:
786 Index add method, for adding co
- Page 1630:
788 Index Binary I/O (continued) cl
- Page 1634:
790 Index Combo boxes ComboBoxDemo.
- Page 1638:
792 Index Declaring static methods,
- Page 1642:
794 Index Fahrenheit, converting Ce
- Page 1646:
796 Index Hardware, 2 Has-a relatio
- Page 1650:
798 Index Interfaces (continued) So
- Page 1654:
800 Index Kilobytes (KBs), 5 Knight
- Page 1658:
802 Index Methods (continued) varia
- Page 1662:
804 Index Ovals, drawing, 483-484,
- Page 1666:
806 Index Read-only streams, 729. s
- Page 1670:
808 Index Static methods in CircleW
- Page 1674:
810 Index toString method (continue
- Page 1678:
This page intentionally left blank
- Page 1682:
Java Quick Reference Console Input
- Page 1686:
35.1 Introduction Many Web sites ma
- Page 1690:
traditional one called bokmål and
- Page 1694:
DateFormat formatter = DateFormat.g
- Page 1698:
javax.swing.JPanel javax.swing.JPan
- Page 1702:
43 panel3.add(panel1, BorderLayout.
- Page 1706:
javax.swing.JPanel javax.swing.JApp
- Page 1710:
71 showDayNames(); // Display day n
- Page 1714:
1 import java.awt.*; 2 impor
- Page 1718:
java.text.NumberFormat +getInstance
- Page 1722:
If you want even more control over
- Page 1726:
51 p2.setLayout(new GridLayout(3, 3
- Page 1730:
A resource bundle is a Java class f
- Page 1734:
Figure 35.10 The program displays t
- Page 1738:
41 // Text fields for monthly payme
- Page 1742:
157 NumberFormat.getCurrencyInstanc
- Page 1746:
characters, Cp939 for Japanese char
- Page 1750:
35.7 In line 73 of WorldClockContro
- Page 1754:
Figure 35.17 The program displays t
- Page 1758:
***This is a bonus Web chapter CHAP
- Page 1762:
class Data members Methods Construc
- Page 1766:
36.4.1 Event Classes and Event List
- Page 1770:
21 /** MyListener class */ 22 class
- Page 1774:
9 4 public class CourseWithActionEv
- Page 1778:
ActionEvent(Object source, int id,
- Page 1782:
Let us define EnrollmentEvent as th
- Page 1786:
26 } 27 28 public ArrayList getStud
- Page 1790:
22 } 23 } 24 } Tim Johnson attempt
- Page 1794:
(Enable MessagePanel to fire Action
- Page 1798:
message “You have an appointment
- Page 1802:
***This is a bonus Web chapter CHAP
- Page 1806:
Figure 37.1 Swing top-level contain
- Page 1810:
The layout manager places the compo
- Page 1814:
«interface» java.awt.LayoutManage
- Page 1818:
51 // Show the first component in c
- Page 1822:
example, the next code adds a rigid
- Page 1826:
79 } Two containers of the Box clas
- Page 1830:
20 add(jbtBlue); 21 add(jbtGreen);
- Page 1834:
Figure 37.8 The DiagonalLayout mana
- Page 1838:
84 public void setMajorDiagonal(boo
- Page 1842:
which in turn invokes the layoutCon
- Page 1846:
To set a corner component, you can
- Page 1850:
77 78 if (location == "UPPER_LEFT_C
- Page 1854:
11 public DisplayFigure() { 12 squa
- Page 1858:
1 import java.awt.*; 2 impo
- Page 1862:
in §12.9, “Common Features of Sw
- Page 1866:
+createBevelBorder(type: int): Bord
- Page 1870:
Create and register listeners to im
- Page 1874:
102 btgBorderStyle.add(jrbEtched);
- Page 1878:
depending on the selection of the r
- Page 1882:
Programming Exercises Section 37.3
- Page 1886:
Figure 37.26 Four figures are displ
- Page 1890:
38.1 Introduction Java provides a c
- Page 1894:
(a) (b) (c) Figure 38.2 (a) A check
- Page 1898:
1. Create a menu bar and set it in
- Page 1902:
98 public void actionPerformed(Acti
- Page 1906:
Figure 38.4 A popup menu is display
- Page 1910:
TIP Java provides a new setCompone
- Page 1914:
The toolbar buttons are floatable.
- Page 1918:
JButton jbt = new JButton(exitActio
- Page 1922:
78 this.name = name; 79 } 80 81 @Ov
- Page 1926:
Figure 38.11 There are five types o
- Page 1930:
methods return a String that is ent
- Page 1934:
4 public static void main(String ar
- Page 1938:
Create a custom dialog component na
- Page 1942:
106 color = new Color(redValue, gre
- Page 1946:
(a) (b) Figure 38.19 An instance of
- Page 1950:
Figure 38.21 The editor enables you
- Page 1954:
108 jta.setBackground(selectedColor
- Page 1958:
Test Questions 3. A popup menu, als
- Page 1962:
menu (see Figure 38.22). Show a mes
- Page 1966:
file name is displayed in the text
- Page 1970:
***This is a bonus Web chapter CHAP
- Page 1974:
The Java event delegation model pro
- Page 1978:
60 61 /** Remove an action event li
- Page 1982:
6 private CircleModel model; 7 priv
- Page 1986:
The controller CircleController pre
- Page 1990:
7 8 // Set properties in the model
- Page 1994:
JavaBeans properties with get and s
- Page 1998:
«interface» javax.swing.SpinnerMo
- Page 2002:
calendarField is Calendar.DAY_OF_WE
- Page 2006:
22 panel1.setLayout(new GridLayout(
- Page 2010:
A JSpinner object can fire javax.sw
- Page 2014:
For example, suppose there are five
- Page 2018:
21 public ListPropertiesDemo() { 22
- Page 2022:
existing items, you have to use a l
- Page 2026:
4 5 public class ListModelDemo exte
- Page 2030:
You can use JList’s default cell
- Page 2034:
Small icon Large icon Figure 39.24
- Page 2038:
JavaBeans properties with get and s
- Page 2042:
Figure 39.27 The image and the text
- Page 2046:
properties can be accessed and modi
- Page 2050:
39.15 Why is the cell renderer for
- Page 2054:
in an ImageViewer. Set the dimensio
- Page 2058:
***This is a bonus Web chapter CHAP
- Page 2062:
NOTE: All the supporting interfaces
- Page 2066:
esizing a column affects the width
- Page 2070:
86 87 // Register and create a list
- Page 2074:
specified cells (lines 30-32). Figu
- Page 2078:
Figure 40.8 shows the properties, c
- Page 2082:
40.4 Auto Sort and Filtering Auto s
- Page 2086:
54 } 55 } The example creates a Tab
- Page 2090:
9 // Create table column names 10 p
- Page 2094:
141 } 142 catch (Exception ex) { 14
- Page 2098:
Table cells are painted by cell ren
- Page 2102:
Create image icons private ImageIco
- Page 2106:
import java.awt.*; import ja
- Page 2110:
1 import java.awt.*; 2 im
- Page 2114:
120 @Override 121 public void actio
- Page 2118:
oot is always the first element (in
- Page 2122:
All the methods related to path sel
- Page 2126:
95 }); 96 } 97 } Four trees are cre
- Page 2130:
4 javax.swing.tree.TreeModel model
- Page 2134:
In graph theory, depth-first traver
- Page 2138:
traversals). Some examples of using
- Page 2142:
the selected paths in a text area,
- Page 2146:
You can choose a selection mode fro
- Page 2150:
79 TreeSelectionModel.DISCONTIGUOUS
- Page 2154:
(DefaultTreeCellRenderer)jTree1.get
- Page 2158:
3. JTable and JTree are in the java
- Page 2162:
(Display a table for data from a te
- Page 2166:
Figure 40.36 The file explorer expl
- Page 2170:
41.1 Introduction The preceding cha
- Page 2174:
jPanel2.setLayout(new BorderLayout(
- Page 2178:
Find the number of columns in the r
- Page 2182:
create table Person ( firstName var
- Page 2186:
} copyFile(); } catch (Exception ex
- Page 2190:
atch updates. If the driver does no
- Page 2194:
public class ScrollUpdateResultSet
- Page 2198:
complex query might not be able to
- Page 2202:
owSet.setCommand("select firstName,
- Page 2206:
20 import java.sql.*; im
- Page 2210:
import java.sql.*; import javax.s
- Page 2214:
** Return the number of columns in
- Page 2218:
Define two classes: TestTableEditor
- Page 2222:
import javax.swi
- Page 2226:
} } }); listSelectionModel.addListS
- Page 2230:
In the preceding statement, the des
- Page 2234:
} Class.forName("com.mysql.jdbc.Dri
- Page 2238:
Test Questions Do the test question
- Page 2242:
Figure 41.8 The Course table is dis
- Page 2246:
***This is a bonus Web chapter CHAP
- Page 2250:
A Web browser requests a static HTM
- Page 2254:
this purpose. Java servlets are Jav
- Page 2258:
Figure 42.3 (a) Choose Web Applicat
- Page 2262:
Figure 42.8 A new servlet class is
- Page 2266:
public void service(ServletRequest
- Page 2270:
HttpServlet inherits abstract class
- Page 2274:
public void destroy() { ... } } //
- Page 2278:
Student Registration Form Studen
- Page 2282:
You can create the HTML file from N
- Page 2286:
(a) (b) Figure 42.18 The GET method
- Page 2290:
If you choose an Asian locale (e.g.
- Page 2294:
State Georgia-GA Oklahoma-OK India
- Page 2298:
} } pstmt.setString(9, zip); pstmt.
- Page 2302:
Using Hidden Data for Session T
- Page 2306:
} "value=" + email + " name=\"email
- Page 2310:
javax.servlet.http.Cookie +Cookie(n
- Page 2314:
} out.println("Street: " + street);
- Page 2318:
Cookies are automatically sent to t
- Page 2322:
public class RegistrationWithHttpSe
- Page 2326:
} } pstmt.setString(2, address.getF
- Page 2330:
} return this.city; } public void s
- Page 2334:
The servlet reads the characters fr
- Page 2338:
(2 * Math.PI / 60))); int ySecond =
- Page 2342:
} } "ImageContentWithDrawing\" alig
- Page 2346:
Section 42.3 42.6 Can you display a
- Page 2350:
42.1* (Factorial table) Write a ser
- Page 2354:
The servlet computes the loan payme
- Page 2358:
42.11* Cookie 3: name is “count
- Page 2362:
***This is a bonus Web chapter CHAP
- Page 2366:
Figure 43.1 You can create a JSP pa
- Page 2370:
A JSP declaration is for declaring
- Page 2374:
equest represents the client’s re
- Page 2378:
What is wrong if the JSP scriptlet
- Page 2382:
Normally you create an instance of
- Page 2386:
The scope attribute specifies the s
- Page 2390:
Instead of using the value attribut
- Page 2394:
} /** Obtain factorial */ public lo
- Page 2398:
FactorialBean Compute Fac
- Page 2402:
} } return dateFormat.format(calend
- Page 2406:
creates a prepared statement for st
- Page 2410:
Listing 43.18 StoreStudent.jsp
- Page 2414:
Listing 43.19 DBBean.java
- Page 2418:
DBLogin JDBC URL jdbc:odbc:Exa
- Page 2422:
%> You start the applic
- Page 2426:
encounter a delay, JSP developers s
- Page 2430:
(Store cookies in JSP) Rewrite Exer
- Page 2434:
(Guess capitals) Write a JSP that p
- Page 2438:
44.1 Introduction The use of ser
- Page 2442:
Figure 44.4 A default JSF page is c
- Page 2446:
NOTE: The XML tag names are case-se
- Page 2450:
Figure 44.8 A JavaBean for JSF was
- Page 2454:
Display Current Time The curre
- Page 2458:
Student Registration
- Page 2462:
Figure 44.12 The resources folder w
- Page 2466:
public String getFirstName() { retu
- Page 2470:
Gender
- Page 2474:
The h:selectManyListbox element is
- Page 2478:
} } The managed bean has three prop
- Page 2482:
Step 2. Create a JSP facelet named
- Page 2486:
Table 44.2 JSF Input Validator Tags
- Page 2490:
For each input tex
- Page 2494:
} } If an input is invalid, its val
- Page 2498:
package jsf2demo; import javax.
- Page 2502:
Display Student
- Page 2506:
} font-size:1em; padding:3px 7px 2p
- Page 2510:
xmlns:f="http://java.sun.com/jsf/co
- Page 2514:
package jsf2demo; import j
- Page 2518:
} public String getRequiredFields()
- Page 2522:
6. In JSF, the objects that are acc
- Page 2526:
44.2* (a) The JSF page displays fac
- Page 2530:
44.8* (a) The program displays five
- Page 2534:
displays four random cards and disp
- Page 2538: 45.1 Introduction Web service is
- Page 2542: } Lines 4-5 import the annotation
- Page 2546: ***END NOTE Where host is the host
- Page 2550: NOTE: When you created a Web servic
- Page 2554: Figure 45.9 The client request and
- Page 2558: Right-click the WebServiceProject n
- Page 2562: The findAddress method searches the
- Page 2566: Figure 45.14 The Address.java is au
- Page 2570: * required fields Lines 2-4
- Page 2574: import java.util.List; import java.
- Page 2578: True False
- Page 2582: Web service Web service client refe
- Page 2586: 45.5* (Quiz) The user needs to answ
- Page 2592: Server stub: An object that resides
- Page 2596: java.rmi.registry.Registry +bind(na
- Page 2600: 2. Create a server implementation n
- Page 2604: import java.rmi.registry.Registry;
- Page 2608: 5.4. Run the client StudentServerIn
- Page 2612: 2. Create a new server implementati
- Page 2616: import java.rmi.registry.*; public
- Page 2620: public interface CallBack extends R
- Page 2624: import java.rmi.server.*; import ja
- Page 2628: } return false; /** Check if the bo
- Page 2632: } // Create cells and place cells i
- Page 2636: } } } getSize().height - 20); } /**
- Page 2640:
Chapter Summary 1. RMI is a high-le
- Page 2644:
***This is a bonus Web chapter CHAP
- Page 2648:
Run from www.cs.armstrong.edu/liang
- Page 2652:
Listing 47.1 Searching an Element i
- Page 2656:
p0 e1 p1 e0 e e2 c0 c1 c2 rightChil
- Page 2660:
Case 1: u is a leaf 3-node or 4-nod
- Page 2664:
Locate the rightmost node in the le
- Page 2668:
16 27 27 34 16 34 3 15 24 25 29 50
- Page 2672:
import java.u
- Page 2676:
} } else { Tree24Node v = new Tree2
- Page 2680:
} } // Get the path that leads to e
- Page 2684:
} // Adjust child links for nonleaf
- Page 2688:
or 3-node, invoke insert23(e, right
- Page 2692:
22 System.out.print("\nAfter insert
- Page 2696:
20 15 24 27 50 3 16 22 23 25 29 60
- Page 2700:
for data stored on secondary storag
- Page 2704:
(a) Before a fusion is performed (b
- Page 2708:
Show the change of a 2-4 tree when
- Page 2712:
***This is a bonus Web chapter CHAP
- Page 2716:
ed node 27 is merged to its parent
- Page 2720:
Figure 48.4 The RBTree class extend
- Page 2724:
w 40 u y3 v 20 30 u x v 20 u 30 40
- Page 2728:
public boolean insert(E
- Page 2732:
sibling of v) (lines 32-33). If x i
- Page 2736:
If u is black and childOfu is red,
- Page 2740:
parent y y1 y u y1 parent childOfu
- Page 2744:
parent y y parent y2 childOfu is do
- Page 2748:
} fixDoubleBlack(grandparentOfu, pa
- Page 2752:
After deleting 25, the new tree is
- Page 2756:
import java.util.Arr
- Page 2760:
} else { // Case 2: v's sibling x i
- Page 2764:
(RBTreeNode)(parent.left) : (RBTree
- Page 2768:
} if (root == null) return; System.
- Page 2772:
Otherwise, y is red. In this case,
- Page 2776:
50 (black) The number of nodes is 7
- Page 2780:
public class TreePerformanceTest
- Page 2784:
7. If the external node to be delet
- Page 2788:
***This is a bonus Web chapter CHAP
- Page 2792:
Java 2D provides facilities to cons
- Page 2796:
ectangular frame. Figure 49.3 shows
- Page 2800:
import java.awt.*; import j
- Page 2804:
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 8 9
- Page 2808:
import java.awt.*; import java.a
- Page 2812:
Figure 49.12 After scaling is appli
- Page 2816:
} } } BasicStroke.JOIN_BEVEL)); g2d
- Page 2820:
A TexturePaint is specified by an i
- Page 2824:
The statement in lines 36-37 Textur
- Page 2828:
} } } // Draw a quadratic curve g2d
- Page 2832:
class ShapePanel extends JPanel { p
- Page 2836:
} Graphics2D g2d = (Graphics2D)g; /
- Page 2840:
import java.awt.*; import jav
- Page 2844:
10. You can specify the width of th
- Page 2848:
(a) (b) Figure 49.27 (c) (d) (e) (a
- Page 2852:
49.11* (Plot the log, n, nlogn, and
- Page 2856:
***This is a bonus Web chapter CHAP
- Page 2860:
The JUnit test runner displays the
- Page 2864:
Figure 50.3 The test report is disp
- Page 2868:
** Construct a loan with specified
- Page 2872:
Figure 50.6 A new project named cha
- Page 2876:
Figure 50.9 The Create Tests dialog
- Page 2880:
Figure 50.12 The New Java Project d
- Page 2884:
Figure 50.14 The Loan class is crea
- Page 2888:
Figure 50.17 The test report is dis