목차 일부
CONTENTS
Preface ... xix
1 Introduction to Computers, the Internet and the Web ... 1
1.1 Introduction ... 2
1.2 What Is a Computer? ... 4
1.3 Computer Organization ... 5
1.4 Evolution of O...
더보기
목차 전체
CONTENTS
Preface ... xix
1 Introduction to Computers, the Internet and the Web ... 1
1.1 Introduction ... 2
1.2 What Is a Computer? ... 4
1.3 Computer Organization ... 5
1.4 Evolution of Operating Systems ... 6
1.5 Personal, Distributed and Client/Server Computing ... 6
1.6 Machine Languages, Assembly Languages and High-Level Languages ... 7
1.7 History of C++ ... 8
1.8 History of Java ... 9
1.9 Java Class Libraries ... 9
1.10 FORTRAN, COBOL, Pascal and Ada ... 11
1.11 BASIC, Visual Basic, Visual C++, C and. NET ... 11
1.12 The Internet and the World Wide Web ... 12
1.13 Basics of a Typical Java Environment ... 13
1.14 General Notes about Java and This Book ... 16
1.15 Thinking About Objects : Introduction to Object Technology and the Unified Modeling Language ... 18
1.16 Discovering Design Patterns : Introduction ... 22
2 Introduction to Java Applications ... 32
2.1 Introduction ... 33
2.2 A First Program in Java : Printing a Line of Text ... 33
2.3 Modifying Our First Java Program ... 40
2.4 Displaying Text in a Dialog Box ... 42
2.5 Another Java Application : Adding Integers ... 47
2.6 Memory Concepts ... 53
2.7 Arithmetic ... 54
2.8 Decision Making : Equality and Relational Operators ... 58
2.9 (Optional Case Study) Thinking About Objects : Examining the Problem Statement ... 64
3 Introduction to Java Applets ... 82
3.1 Introduction ... 83
3.2 Sample Applets from the Java 2 Software Development Kit ... 83
3.3 Simple Java Applet : Drawing a String ... 89
3.4 Drawing Strings and Lines ... 98
3.5 Adding Floating - Point Numbers ... 100
3.6 Java Applet Internet and World Wide Web Resources ... 107
3.7 (Optional Case Study) Thinking About Objects : Identifying the Classes in a Problem Statement ... 108
4 Control Statements : Part 1 ... 119
4.1 Introduction ... 120
4.2 Algorithms ... 120
4.3 Pseudocode ... 121
4.4 Control Structures ... 121
4.5 if Single-Selection Statement ... 124
4.6 if...else Selection Statement ... 126
4.7 Wh i1e Repetition Statement ... 130
4.8 Formulating Algorithms : Case Study 1(Counter-Controlled Repetition) ... 132
4.9 Formulating Algorithms with Top - Down, Stepwise Refinement : Case Study 2(Sentinel-Controlled Repetition) ... 136
4.10 Formulating Algorithms with Top - Down, Stepwise Refinement : Case Study 3(Nested Control Structures) ... 144
4.11 Compound Assignment Operators ... 149
4.12 Increment and Decrement Operators ... 149
4.13 Primitive Types ... 152
4.14 (Optional Case Study) Thinking About Objects : Identifying Class Attributes ... 154
5 Control Statements : Part 2 ... 168
5.1 Introduction ... 169
5.2 Essentials of Counter - Controlled Repetition ... 169
5.3 for Repetition Statement ... 171
5.4 Examples Using the for Statement ... 176
5.5 do...while Repetition Statement ... 181
5.6 switch Multiple-Selection Statement ... 183
5.7 break and continue Statements ... 188
5.8 Labeled break and continue Statements ... 190
5.9 Logical Operators ... 193
5.10 Structured Programming Summary ... 199
5.11 (Optional Case Study) Thinking About Objects : Identifying Objects' States and Activities ... 204
6 Methods ... 216
6.1 Introduction ... 217
6.2 Program Modules in Java ... 217
6.3 Math-Class Methods ... 219
6.4 Method Declarations ... 221
6.5 Argument Promotion ... 227
6.6 Java API Packages ... 228
6.7 Random-Number Generation ... 230
6.8 Example : A Game of Chance ... 234
6.9 Scope of Declarations ... 242
6.10 Methods of Class JApplet ... 246
6.11 Method Overloading ... 247
6.12 Recursion ... 250
6.13 Example Using Recursion : The Fibonacci Series ... 253
6.14 Recursion vs. Iteration ... 258
6.15 (Optional Case Study) Thinking About Objects : Identifying Class Operations ... 260
7 Arrays ... 279
7.1 Introduction ... 280
7.2 Arrays ... 280
7.3 Declaring and Creating Arrays ... 282
7.4 Examples Using Arrays ... 283
7.5 References and Reference Parameters ... 293
7.6 Passing Arrays to Methods ... 294
7.7 Sorting Arrays ... 296
7.8 Searching Arrays : Linear Search and Binary Search ... 299
7.9 Multidimensional Arrays ... 306
7.10 (Optional Case Study) Thinking About Objects : Collaboration Among Objects ... 314
8 Object-Based Programming ... 341
8.1 Introduction ... 342
8.2 Implementing a Time Abstract Data Type with a Class ... 343
8.3 Class Scope ... 351
8.4 Controlling Access to Members ... 351
8.5 Referring to the Current Object's Members with this ... 352
8.6 Initializing Class Objects : Constructors ... 354
8.7 Using Overloaded Constructors ... 355
8.8 Using Set and Get Methods ... 360
8.9 Composition ... 368
8.10 Garbage Collection ... 371
8.11 Static Class Members ... 372
8.12 Final Instance Variables ... 377
8.13 Creating Packages ... 379
8.14 Package Access ... 384
8.15 Software Reusability ... 386
8.16 Data Abstraction and Encapsulation ... 387
8.17 (Optional Case Study) Thinking About Objects : Starting to Program the Classes for the Elevator Simulation ... 389
9 Object-Oriented Programming : Inheritance ... 400
9.1 Introduction ... 401
9.2 Superclasses and Subclasses ... 402
9.3 protected Members ... 404
9.4 Relationship between Superclasses and Subclasses ... 405
9.5 Case Study : Three-Level Inheritance Hierarchy ... 424
9.6 Constructors and Finalizers in Subclasses ... 427
9.7 Software Engineering with Inheritance ... 432
10 Object-Oriented Programming : Polymorphism ... 437
10.1 Introduction ... 438
10.2 Relationships Among Objects in an Inheritance Hierarchy ... 439
10.2.1 Invoking Superclass Methods from Subclass Objects ... 440
10.2.2 Using Superclass References with Subclass-Type Variables ... 441
10.2.3 Subclass Method Calls via Superclass-Type Variables ... 442
10.3 Polymorphism Examples ... 445
10.4 Abstract Classes and Methods ... 446
10.5 Case Study : Inheriting Interface and Implementation ... 448
10.6 final Methods and Classes ... 456
10.7 Case Study : Payroll System Using Polymorphism ... 457
10.8 Case Study : Creating and Using Interfaces ... 467
10.9 Nested Classes ... 472
10.10 Type-Wrapper Classes for Primitive Types ... 485
10.11 (Optional Case Study) Thinking About Objects : Incorporating Inheritance into the Elevator Simulation ... 485
10.12 (Optional) Discovering Design Patterns : Introducing Creational, Structural and Behavioral Design Patterns ... 492
10.12.1 Creational Design Patterns ... 493
10.12.2 Structural Design Patterns ... 496
10.12.3 Behavioral Design Patterns ... 496
10.12.4 Conclusion ... 498
10.12.5 Internet and World-Wide-Web Resources ... 499
11 Strings and Characters ... 505
11.1 Introduction ... 506
11.2 Fundamentals of Characters and Strings ... 507
11.3 Class String ... 507
11.3.1 String Constructors ... 507
11.3.2 String Methods length, charAt and getChars ... 509
11.3.3 Comparing Strings ... 511
11.3.4 Locating Characters and Substrings in Strings ... 515
11.3.5 Extracting Substrings from Strings ... 518
11.3.6 Concatenating Strings ... 519
11.3.7 Miscellaneous String Methods ... 519
11.3.8 String Method valueOf ... 521
11.4 Class StringBuffer ... 523
11.4.1 StringBuffer Constructors ... 523
11.4.2 StringBuffer Methods Iength, capacity, setLength and ensureCapacity ... 524
11.4.3 StringBuffer Methods charAt, setCharAt, getChars and reverse ... 525
11.4.4 StringBuffer append Methods ... 527
11.4.5 StringBuffer Insertion and Deletion Methods ... 529
11.5 Class Character ... 530
11.6 Class StringTokenizer ... 537
11.7 Card Shuffling and Dealing Simulation ... 539
11.8 Regular Expressions, Class Pattern and Class Matcher ... 543
11.9 (Optional Case Study) Thinking About Objects : Event Handling ... 553
12 Graphics and Java2D ... 569
12.1 Introduction ... 570
12.2 Graphics Contexts and Graphics Objects ... 572
12.3 Color Control ... 573
12.4 Font Control ... 580
12.5 Drawing Lines, Rectangles and Ovals ... 585
12.6 Drawing Arcs ... 589
12.7 Drawing Polygons and Polylines ... 591
12.8 Java2D API ... 594
12.9 (Optional Case Study) Thinking About Objects : Designing Interfaces with the UML ... 601
13 Graphical User Interface Components : Part 1 ... 611
13.1 Introduction ... 612
13.2 Overview of Swing Components ... 613
13.3 JLabel ... 616
13.4 Event Handling ... 619
13.5 Textfields ... 620
13.6 How Event Handling Works ... 625
13.7 JButton ... 626
13.8 JCheckBox and JRadi oButton ... 629
13.9 JComboBox ... 634
13.10 JList ... 637
13.11 Multiple-Selection Lists ... 639
13.12 Mouse Event Handling ... 642
13.13 Adapter Classes ... 646
13.14 Key Event Handling ... 651
13.15 Layout Managers ... 654
13.15.1 FlowLayout ... 655
13.15.2 BorderLayout ... 658
13.15.3 GridLayout ... 661
13.16 Panels ... 663
13.17 (Optional Case Study) Thinking About Objects : Use Cases ... 664
14 Graphical User Interface Components : Part 2 ... 677
14.1 Introduction ... 678
14.2 JTextArea ... 679
14.3 Creating a Customized Subclass of JPanel ... 682
14.4 JPanel Subclass that Handles Its Own Events ... 686
14.5 JSlider ... 691
14.6 Windows : Additional Notes ... 695
14.7 Using Menus with Frames ... 696
14.8 JPopupMenu ... 704
14.9 Pluggable Look-and-Feel ... 707
14.10 JDesktopPane and JInternalFrame ... 711
14.11 JTabbedPane ... 715
14.12 Layout Managers : BoxLayout and GridBagLayout ... 717
14.13 (Optional Case Study) Thinking About Objects : Model-View- Controller ... 729
14.14 (Optional) Discovering Design Patterns : Design Patterns Used in Packages java. awt and javax. swing ... 738
14.14.1 Creational Design Patterns ... 738
14.14.2 Structural Design Patterns ... 739
14.14.3 Behavioral Design Patterns ... 741
14.14.4 Conclusion ... 744
15 Exception Handling ... 751
15.1 Introduction ... 752
15.2 Exception-Handling Overview ... 753
15.3 Exception- Handling Example : Divide by Zero ... 756
15.4 Java Exception Hierarchy ... 760
15.5 Rethrowing an Exception ... 762
15.6 final1y Clause ... 762
15.7 Stack Unwinding ... 766
15.8 printStackTrace, getStackTrace and getMessage ... 767
15.9 Chained Exceptions ... 770
15.10 Declaring New Exception Types ... 772
15.11 Constructors and Exception Handling ... 773
16 Multithreading ... 778
16.1 Introduction ... 779
16.2 Thread States : Life Cycle of a Thread ... 781
16.3 Thread Priorities and Thread Scheduling ... 783
16.4 Creating and Executing Threads ... 785
16.5 Thread Synchronization ... 787
16.6 Producer/Consumer Relationship without Synchronization ... 789
16.7 Producer/Consumer Relationship with Synchronization ... 795
16.8 Producer/Consumer Relationship : Circular Buffer ... 802
16.9 Daemon Threads ... 814
16.10 Runnable Interface ... 814
16.11 (Optional Case Study) Thinking About Objects : Multithreading ... 820
16.12 (Optional) Discovering Design Patterns : Concurrent Design Patterns ... 824
17 Files and Streams ... 833
17.1 Introduction ... 834
17.2 Data Hierarchy ... 835
17.3 Files and Streams ... 837
17.4 Class File ... 840
17.5 Creating a Sequential-Access File ... 846
17.6 Reading Data from a Sequential-Access File ... 857
17.7 Updating Sequential-Access Files ... 869
17.8 Random-Access Files ... 869
17.9 Creating a Random-Access File ... 870
17.10 Writing Data Randomly to a Random-Access File ... 875
17.11 Reading Data Sequentially from a Random-Access File ... 880
17.12 Case Study : A Transaction- Proce s sing Program ... 885
17.13 New I/O APIs for the Java Platform ... 897
18 Networking ... 914
18.1 Introduction ... 915
18.2 Manipulating URLs ... 917
18.3 Reading a File on a Web Server ... 922
18.4 Establishing a Simple Server Using Stream Sockets ... 925
18.5 Establishing a Simple Client Using Stream Sockets ... 927
18.6 Client/Server Interaction with Stream Socket Connections ... 927
18.7 Connectionless Client/Server Interaction with Datagrams ... 940
18.8 Client/Server Tic-Tac-Toe Using a Multithreaded Server ... 947
18.9 Security and the Network ... 961
18.10 DeitelMessenger Chat Server and Client ... 962
18.10.1 DeitelMessengerServer and Supporting Classes ... 962
18.10.2 DeitelMessenger Client and Supporting Classes ... 972
18.11 NIO Networking Overview ... 990
18.12 (Optional) Discovering Design Patterns : Design Patterns Used in Packages java.io and java.net ... 1002
18.12.1 Creational Design Patterns ... 1002
18.12.2 Structural Design Patterns ... 1003
18.12.3 Architectural Patterns ... 1004
18.12.4 Conclusion ... 1006
19 Multimedia : Images, Animation and Audio ... 1014
19.1 Introduction ... 1015
19.2 Loading, Displaying and Scaling Images ... 1016
19.3 Animating a Series of Images ... 1019
19.4 Image Maps ... 1022
19.5 Loading and Playing Audio Clips ... 1025
19.6 Internet and World Wide Web Resources ... 1028
19.7 (Optional Case Study) Thinking About Objects : Animation and Sound in the View ... 1030
20 Data Structures ... 1048
20.1 Introduction ... 1049
20.2 Self- Referential Classes ... 1050
20.3 Dynamic Memory Allocation ... 1050
20.4 Linked Lists ... 1051
20.5 Stacks ... 1061
20.6 Queues ... 1066
20.7 Trees ... 1069
21 Java Utilities Package and Bit Manipulation ... 1098
21.1 Introduction ... 1099
21.2 Vector Class and Enumeration Interface ... 1099
21.3 Stack Class of Package java.util ... 1103
21.4 Hashtable Class ... 1106
21.5 Properties Class ... 1110
21.6 Bit Manipulation and the Bitwise Operators ... 1117
21.7 BitSet Class ... 1131
22 Collections ... 1140
22.1 Introduction ... 1141
22.2 Collections Overview ... 1142
22.3 Class Arrays ... 1142
22.4 Interface Collection and Class Collections ... 1147
22.5 Lists ... 1147
22.6 Algorithms ... 1154
22.6.1 Algorithm sort ... 1154
22.6.2 Algorithm shuffle ... 1158
22.6.3 Algorithms reverse, fill, copy, max and min ... 1160
22.6.4 Algorithm binarySearch ... 1162
22.7 Sets ... 1164
22.8 Maps ... 1167
22.9 Synchronization Wrappers ... 1170
22.10 Unmodifiable Wrappers ... 1170
22.11 Abstract Implementations ... 1171
22.12 (Optional) Discovering Design Patterns : Design Patterns Used in Package java.util ... 1171
22.12.1 Creational Design Patterns ... 1171
22.12.2 Behavioral Design Patterns ... 1172
22.12.3 Conclusion ... 1172
23 Java Database Connectivity with JDBC™ ... 1178
23.1 Introduction ... 1179
23.2 Relational Databases ... 1180
23.3 Relational Database Overview : The books Database ... 1181
23.4 SQL ... 1185
23.4.1 Basic SELECT Query ... 1185
23.4.2 WHERE Clause ... 1187
23.4.3 ORDER BY Clause ... 1188
23.4.4 Merging Data from Multiple Tables : INNER JOIN ... 1191
23.4.5 INSERT Statement ... 1192
23.4.6 UPDATE Statement ... 1193
23.4.7 DELETE Statement ... 1193
23.5 Creating Database books in Cloudscape ... 1194
23.6 Manipulating Databases with JDBC ... 1195
23.6.1 Connecting to and Querying a Database ... 1195
23.6.2 Querying the books Database ... 1201
23.7 Stored Procedures ... 1212
23.8 Internet and World Wide Web Resources ... 1212
24 Servlets ... 1220
24.1 Introduction ... 1221
24.2 Servlet Overview and Architecture ... 1223
24.2.1 Interface Servlet and the Servlet Life Cycle ... 1224
24.2.2 HttpServlet Class ... 1226
24.2.3 HttpServletRequest Interface ... 1227
24.2.4 HttpServletResponse Interface ... 1228
24.3 Handling HTTP get Requests ... 1229
24.3.1 Setting Up the Apache Tomcat Server ... 1233
24.3.2 Deploying a Web Application ... 1235
24.4 Handling HTTP get Requests Containing Data ... 1239
24.5 Handling HTTP post Requests ... 1242
24.6 Redirecting Requests to Other Resources ... 1245
24.7 Multi-Tier Applications : Using JDBC from a Servlet ... 1249
24.8 Internet and World Wide Web Resources ... 1255
25 JavaServer Pages(JSP) ... 1261
25.1 Introduction ... 1262
25.2 JavaServer Pages Overview ... 1262
25.3 First JavaServer Page Example ... 1263
25.4 Implicit Objects ... 1266
25.5 Scripting ... 1267
25.5.1 Scripting Components ... 1267
25.5.2 Scripting Example ... 1269
25.6 Standard Actions ... 1271
25.6.1 <jsp : include> Action ... 1272
25.6.2 <jsp : forward> Action ... 1277
25.6.3 <jsp : useBean> Action ... 1281
25.7 Directives ... 1285
25.7.1 page Directive ... 1286
25.7.2 include Directive ... 1288
25.8 Case Study : Guest Book ... 1290
25.9 Internet and World Wide Web Resources ... 1301
A Operator Precedence Chart ... 1307
B ASCII Character Set ... 1309
C Number Systems ... 1310
C.1 Introduction ... 1311
C.2 Abbreviating Binary Numbers as Octal Numbers and Hexadecimal Numbers ... 1314
C.3 Converting Octal Numbers and Hexadecimal Numbers to Binary Numbers ... 1315
C.4 Converting from Binary, Octal or Hexadecimal to Decimal ... 1315
C.5 Converting from Decimal to Binary, Octal or Hexadecimal ... 1316
C.6 Negative Binary Numbers : Two's Complement Notation ... 1318
D Elevator Events and Listener Interfaces ... 1323
D.1 Introduction ... 1323
D.2 Events ... 1323
D.3 Listeners ... 1327
D.4 Artifacts Revisited ... 1330
E Elevator Model ... 1332
E.1 Introduction ... 1332
E.2 Class ElevatorSimulation ... 1332
E.3 Classes Location and Floor ... 1340
E.4 Classes Door and ElevatorDoor ... 1343
E.5 Class Button ... 1347
E.6 Class ElevatorShaft ... 1349
E.7 Classes Light and Bell ... 1356
E.8 Class Elevator ... 1360
E.9 Class Person ... 1368
E.10 Artifacts Revisited ... 1375
E.11 Conclusion ... 1375
F Elevator View(on CD) ... 1377
F.1 Introduction ... 1377
F.2 Class Objects ... 1394
F.3 Class Constants ... 1396
F.4 Class Constructor ... 1397
F.5 Event Handling ... 1398
F.5.1 ElevatorMoveEvent types ... 1398
F.5.2 PersonMoveEvent types ... 1399
F.5.3 DoorEvent types ... 1400
F.5.4 ButtonEvent types ... 1401
F.5.5 BellEvent types ... 1401
F.5.6 LightEvent types ... 1401
F.6 Artifacts Revisited ... 1401
F.7 Conclusion ... 1402
G Unicodes ... 1403
G.1 Introduction ... 1404
G.2 Unicode Transformation Formats ... 1405
G.3 Characters and Glyphs ... 1406
G.4 Advantages/Disadvantages of Unicode ... 1407
G.5 Unicode Consortium's Web Site ... 1407
G.6 Using Unicode ... 1408
G.7 Character Ranges ... 1411
Bibliography ... 1415
Index ... 1418
더보기 닫기