折叠 编辑本段 内容简介
本书对面向对象的思想和机制进行了准确而透彻的剖析,腊故项促为读者深入学习Java语言程序设计提供了全面、详细的指导,并在前几版的基础上进行了全面通象的修订与更新。全书覆盖了面向对象设计的广泛内容,介绍了Java语言的基挨尝匙本数据类型、流程控制才和乃耻定炒、类和对象等。在深入分析面向对象设计方法的基础上,介绍了封多富双乡粮红合席条润榆煮装机制、继承机制和多态性的实现与应用巩试希、异常的捕捉和处理、集合类的定义方法和泛型类的概念,书中提供了大量具有可实红族执掌也践性的程序实例、自测题及答案、练习题和编程项目、生拘照动的""软件失误案例"和""视频讲解"学习辅导短片,并且省顺的触认满在每章中都补充了针对本欢州酒题限具见室维开章主题的图形用户界面(GUI)设计知识和实例,这部分内容传析妒部医声极程滑可形成完整的Java GUI设计知识体系。此外,本书还有内容丰富的附录,并提供了在线程序设计实践网站服务。
折叠 编辑本段 图书目录
Contents
Chapter 1 Introduction 1
轴灯心1.1 Computer Processing 2
Software Categories 3
Digital Computers 5
Binary Numbers 7
1.2 Hardware Components 10
Computer Architecture 11
Input/Output Devices 12
Main Memory 单封杀市倒and Secondary Memory 13
The Central Processing Unit 17
1.3 Networks 20
Network Connections 20
Local-Area Net宁电儿讲侵祖余房works and Wide-Area Networks 22
The Internet 23
The World Wide Web 24
Uni掉较团击政盟止form Resource Locators 25
1.4 The Java Programming Language 26
A Java Program 28
Comments 30
Identifiers and Reserved Words 31
White S厂pace 34
1.5 Program Development 36
Programming 穿底节考朝缺Language Levels 36
Editors, Compilers, and Interpreters 39
Development Environments 40
Syntax and Semantics 41
Errors 42
1.6 Object-Ori抗适ented Programming 44
Problem So假华换调善医供仅带院lving 45
Object-Oriented Software Principles 46
Chapter 2 Data and Expressions 57
2.1 Character Strings 58
The print and println Methods 白黄府局毛身纸端克滑钟58
String Concatenation 60
再丰答效仍更带Escape Sequences 63
2.2 Variables and Assignment 65
Variable将s 65
The Assignme五助架裂弦伤调取穿nt Statement 67
Constants 69
2.3 Primitiv掉善块点证量e Data Types 71
Integers and Floating Points 71
Characters 73
Bool肉河卫扬阳把宜果当eans 74
2.4 Expressions 75
Arithmetic Operators 75
Operator Precedence 76
Increment and Decrement Operators 80
Assignment Operators 81
2.5 Data Conversion 83
Conversion Techniques 85
2你难础感再.6 Interactive Programs 87
The Scanner Class 87
2.7 Graph上五量赵写地眼体结ics 92
Coordinate Systems 92
Representing Color 94
2.8 Applets 95
Executing Applets Using the Web 98
2.9 Drawin生提财给是住七完答物合g Shapes 99
The Graphi三取cs Class 99
Sof合板金盐题怎帮直tware Failure:
NASA Mars Climate Orbiter and Polar Lander 111
Chapter 3 Using Classes and Objects 113
3.1 Creating Objects 114
Aliases 116
3.2 The String Class 118
3.3 P输附ackages 122
The import Declaration 124
3.4 The Random Class 126
3故医使黑巴波北外铁.5 The Math Class 129
3.6 Formatting Output 132
The NumberForma露操量t Class 132
The DecimalFormat Class 134
The printf Method 135
3.7 Enumerate就d Types 138
3.8 Wrapper Classes 141
Au轮破千谓村娘草我toboxing 143
3.9 Components and Containers 143
Frames and Panels 144
3.10 Nested Panels 148
3.11 Images 151
Chapte迅r 4 Writing Classes 159
4.1 C世巴送祖修如没放干lasses and Objects Revisited 160
4.2 Anatomy of 友集间北把振田章冷年乡a Class 162
In哪路干段晚模为stance Da报盐举流点假谓并钱点ta 167
UML C局南政算电曲简究且动lass Diagrams 167
4.3 Enca影水矛心家按psulation 169
Visibility Modifiers 170
Accessors and Mutators 171
4.4 Anatomy of a Method 172
The ret艺会urn Statement 174
Parameters 175
Local Data 175
Bank Accoun效让设并远编法慢二刚师t Example 波海静立介愿械除它176
4.5 Constructors Revisited 181
4.6 Graphical Objects 18化2
4.7 Graphical User Interfaces 191
4.8 Buttons 192
4.9 Text Fields 196
Softw诉纪故增钱里倍打are Failure:
Denver Airport Ba进某敌误肥轻突李样候硫ggage Handling System 205
C攻模治跳青既思露罗呼害hapter 5 Conditionals and Loops 207
5.1 Boolean Expressions 208
Equality and Relational Operators 209
Log位管先便ical Operators 210
5.2 The if Statement 213
The if-else Statement 216
Using Block Statements 219
Nested if Statements 223
5.3 Comparing Data 226
Comparing Floats 226
Comparing Characters 227
Comparing Objects 228
5.4 The while Sta护移宗企影便承背无tement 230
Infinite Loops 234
Nested Loops 236
The break and continue Statements 239
政岩越呢末谈乙用5.5 Iterators 241
Reading Text Files 242
5.6 The ArrayList Class 245
5.7 Determining Event Sources 248
5.8 C heck Boxes and Radio Buttons 251
Check Boxes 251
Radio Buttons 255
Software Failure:
Therac-25 267
Chapter 6 More Conditionals and Loops 269
6.1 The switch Statement 270
6.2 The Conditional Operator 274
6.3 The do Statement 275
6.4 The for Statement 279
The for-each Loop 282
Comparing Loops 284
6.5 Drawing with Loops and Conditionals 285
6.6 Dialog Boxes 291
Chapter 7 Object-Oriented Design 301
7.1 Software Development Activities 302
7.2 Identifying Classes and Objects 303
Assigning Responsibilities 305
7.3 Static Class Members 305
Static Variables 306
Static Methods 306
7.4 C lass Relationships 310
Dependency 310
Dependencies Among Objects of the Same Class 310
Aggregation 316
The this Reference 320
7.5 Interfaces 322
The Comparable Interface 327
The Iterator Interface 328
7.6 Enumerated Types Revisited 329
7.7 Method Design 332
Method Decomposition 333
Method Parameters Revisited 338
7.8 Method Overloading 343
7.9 Testing 345
Reviews 346
Defect Testing 346
7.10 GUI Design 349
7.11 Layout Managers 350
Flow Layout 352
Border Layout 356
Grid Layout 359
Box Layout 361
7.12 Borders 365
7.13 C ontainment Hierarchies 369
Software Failure:
2003 Northeast Blackout 377
Chapter 8 A rrays 379
8.1 A rray Elements 380
8.2 Declaring and Using Arrays 381
Bounds Checking 384
Alternate Array Syntax 389
Initializer Lists 389
Arrays as Parameters 390
8.3 A rrays of Objects 392
8.4 C ommand-Line Arguments 402
8.5 Variable Length Parameter Lists 404
8.6 Two-Dimensional Arrays 408
Multidimensional Arrays 412
8.7 P olygons and Polylines 413
The Polygon Class 416
8.8 Mouse Events 418
8.9 Key Events 427
Software Failure:
LA Air Traffic Control 441
Chapter 9 Inheritance 443
9.1 C reating Subclasses 444
The protected Modifier 447
The super Reference 450
Multiple Inheritance 453
9.2 Overriding Methods 455
Shadowing Variables 457
9.3 C lass Hierarchies 458
The Object Class 460
Abstract Classes 461
Interface Hierarchies 463
9.4 Visibility 463
9.5 Designing for Inheritance 466
Restricting Inheritance 467
9.6 The Component Class Hierarchy 468
9.7 Extending Adapter Classes 471
9.8 The Timer Class 475
Software Failure:
Ariane 5 Flight 501 485
Chapter 10 P olymorphism 487
10.1 Late Binding 488
10.2 P olymorphism via Inheritance 489
10.3 P olymorphism via Interfaces 502
10.4 Sorting 504
Selection Sort 505
Insertion Sort 511
Comparing Sorts 512
10.5 Searching 513
Linear Search 513
Binary Search 515
Comparing Searches 519
10.6 Designing for Polymorphism 519
10.7 Event Processing 521
10.8 F ile Choosers 522
10.9 C olor Choosers 525
10.10 Sliders 527
Chapter 11 Exceptions 537
11.1 Exception Handling 538
11.2 Uncaught Exceptions 539
11.3 The try-catch Statement 540
The finally Clause 544
11.4 Exception Propagation 545
11.5 The Exception Class Hierarchy 549
Checked and Unchecked Exceptions 552
11.6 I/O Exceptions 553
11.7 Tool Tips and Mnemonics 557
11.8 C ombo Boxes 564
11.9 Scroll Panes 569
11.10 Split Panes 572
Chapter 12 R ecursion 583
12.1 R ecursive Thinking 584
Infinite Recursion 584
Recursion in Math 585
12.2 R ecursive Programming 586
Recursion vs. Iteration 589
Direct vs. Indirect Recursion 589
12.3 Using Recursion 590
Traversing a Maze 591
The Towers of Hanoi 596
12.4 R ecursion in Graphics 601
Tiled Pictures 601
Fractals 604
Chapter 13 Collections 617
13.1 C ollections and Data Structures 618
Separating Interface from Implementation 618
13.2 Dynamic Representations 619
Dynamic Structures 619
A Dynamically Linked List 620
Other Dynamic List Representations 625
13.3 Linear Data Structures 627
Queues 627
Stacks 628
13.4 Non-Linear Data Structures 631
Trees 631
Graphs 632
13.5 The Java Collections API 634
Generics 634
Appendix A Glossary 641
Appendix B Number Systems 665
Appendix C The Unicode Character Set 673
Appendix D Java Operators 677
Appendix E Java Modifiers 683
Appendix F Java Coding Guidelines 687
Appendix G Java Applets 693
Appendix H R egular Expressions 695
Appendix I Javadoc Documentation Generator 697
Appendix J The PaintBox Project 703
Appendix K GUI Events 715
Appendix L Java Syntax 719
Appendix M The Java Class Library 733
Appendix N A nswers to Self-Review Questions 735
Index 789