Author(s): Cay Horstmann
Edition: 3
Publisher: Wiley
Year: 2016
Language: English
Pages: 985
Tags: java for everyone
Cover......Page 1
Title Page......Page 5
Copyright......Page 6
Preface......Page 7
Contents......Page 21
Chapter 1 Introduction......Page 35
1.1 Computer Programs......Page 36
1.2 The Anatomy of a Computer......Page 37
1.3 The Java Programming Language......Page 40
1.4 Becoming Familiar with Your Programming Environment......Page 41
1.5 Analyzing Your First Program......Page 45
1.6 Errors......Page 48
1.7 Problem Solving: Algorithm Design......Page 49
Chapter 2 Fundamental Data Types......Page 65
2.1 Variables......Page 66
2.2 Arithmetic......Page 77
2.3 Input and Output......Page 84
2.4 Problem Solving: First Do It By Hand......Page 93
2.5 Strings......Page 95
Chapter 3 Decisions......Page 121
3.1 The if Statement......Page 122
3.2 Comparing Numbers and Strings......Page 128
3.3 Multiple Alternatives......Page 136
3.4 Nested Branches......Page 140
3.5 Problem Solving: Flowcharts......Page 145
3.6 Problem Solving: Test Cases......Page 148
3.7 Boolean Variables and Operators......Page 151
3.8 Application: Input Validation......Page 156
Chapter 4 Loops......Page 181
4.1 The while Loop......Page 182
4.2 Problem Solving: Hand-Tracing......Page 189
4.3 The for Loop......Page 192
4.4 The do Loop......Page 198
4.5 Application: Processing Sentinel Values......Page 200
4.6 Problem Solving: Storyboards......Page 204
4.7 Common Loop Algorithms......Page 207
4.8 Nested Loops......Page 214
4.9 Problem Solving: Solve a Simpler Problem First......Page 218
4.10 Application: Random Numbers and Simulations......Page 222
Chapter 5 Methods......Page 259
5.1 Methods as Black Boxes......Page 260
5.2 Implementing Methods......Page 262
5.3 Parameter Passing......Page 265
5.4 Return Values......Page 268
5.5 Methods Without Return Values......Page 272
5.6 Problem Solving: Reusable Methods......Page 273
5.7 Problem Solving: Stepwise Refinement......Page 277
5.8 Variable Scope......Page 284
5.9 Recursive Methods (Optional)......Page 288
Chapter 6 Arrays and Array Lists......Page 319
6.1 Arrays......Page 320
6.2 The Enhanced for Loop......Page 327
6.3 Common Array Algorithms......Page 328
6.4 Using Arrays with Methods......Page 338
6.5 Problem Solving: Adapting Algorithms......Page 342
6.6 Problem Solving: Discovering Algorithms by Manipulating Physical Objects......Page 349
6.7 Two-Dimensional Arrays......Page 352
6.8 Array Lists......Page 359
Chapter 7 Input/Output and Exception Handling......Page 397
7.1 Reading and Writing Text Files......Page 398
7.2 Text Input and Output......Page 403
7.3 Command Line Arguments......Page 411
7.4 Exception Handling......Page 418
7.5 Application: Handling Input Errors......Page 427
Chapter 8 Objects and Classes......Page 445
8.1 Object-Oriented Programming......Page 446
8.2 Implementing a Simple Class......Page 448
8.3 Specifying the Public Interface of a Class......Page 451
8.4 Designing the Data Representation......Page 455
8.5 Implementing Instance Methods......Page 456
8.6 Constructors......Page 459
8.7 Testing a Class......Page 463
8.8 Problem Solving: Tracing Objects......Page 469
8.9 Object References......Page 473
8.10 Static Variables and Methods......Page 478
8.11 Problem Solving: Patterns for Object Data......Page 480
8.12 Packages......Page 487
Chapter 9 Inheritance and Interfaces......Page 513
9.1 Inheritance Hierarchies......Page 514
9.2 Implementing Subclasses......Page 518
9.3 Overriding Methods......Page 522
9.4 Polymorphism......Page 528
9.5 Object: The Cosmic Superclass......Page 539
9.6 Interface Types......Page 546
Chapter 10 Graphical User Interfaces......Page 575
10.1 Frame Windows......Page 576
10.2 Events and Event Handling......Page 580
10.3 Processing Text Input......Page 591
10.4 Creating Drawings......Page 597
Chapter 11 Advanced User Interfaces......Page 625
11.1 Layout Management......Page 626
11.2 Choices......Page 628
11.3 Menus......Page 639
11.4 Exploring the Swing Documentation......Page 646
11.5 Using Timer Events for Animations......Page 651
11.6 Mouse Events......Page 654
Chapter 12 Object-Oriented Design......Page 689
12.1 Classes and Their Responsibilities......Page 690
12.2 Relationships Between Classes......Page 694
12.3 Application: Printing an Invoice......Page 701
Chapter 13 Recursion......Page 739
13.1 Triangle Numbers......Page 740
13.2 Recursive Helper Methods......Page 748
13.3 The Efficiency of Recursion......Page 750
13.4 Permutations......Page 755
13.5 Mutual Recursion......Page 760
13.6 Backtracking......Page 766
Chapter 14 Sorting and Searching......Page 791
14.1 Selection Sort......Page 792
14.2 Profiling the Selection Sort Algorithm......Page 795
14.3 Analyzing the Performance of the Selection Sort Algorithm......Page 798
14.4 Merge Sort......Page 803
14.5 Analyzing the Merge Sort Algorithm......Page 806
14.6 Searching......Page 810
14.7 Problem Solving: Estimating the Running Time of an Algorithm......Page 815
14.8 Sorting and Searching in the Java Library......Page 820
Chapter 15 The Java Collections Framework......Page 837
15.1 An Overview of the Collections Framework......Page 838
15.2 Linked Lists......Page 841
15.3 Sets......Page 847
15.4 Maps......Page 852
15.5 Stacks, Queues, and Priority Queues......Page 858
15.6 Stack and Queue Applications......Page 861
Appendix A The Basic Latin and Latin-1 Subsets of Unicode......Page 891
Appendix B Java Operator Summary......Page 895
Appendix C Java Reserved Word Summary......Page 897
Appendix D The Java Library......Page 899
Introduction......Page 919
Classes......Page 920
Variables and Constants......Page 921
Control Flow......Page 922
Lexical Issues......Page 924
The Java Compiler......Page 926
The JAR Tool......Page 927
Documentation Comments......Page 928
Binary Numbers......Page 930
Overflow and Roundoff Errors......Page 932
Two’s Complement Integers......Page 933
IEEE Floating-Point Numbers......Page 934
Hexadecimal Numbers......Page 935
Bit and Shift Operations......Page 936
UML Diagrams......Page 938
Variables......Page 941
Classes......Page 942
Enumeration Types......Page 944
Methods......Page 945
Statements......Page 947
Packages......Page 950
Comments......Page 951
Appendix J HTML Summary......Page 952
Glossary......Page 957
Index......Page 965
Credits......Page 983
EULA......Page 985