PREFACE V SPECIAL FEATURES XXIV CHATER 1 INTRODUCTION 1 1.1 Computer Programs 2 1.2 The Anatomy of a Computer 3 1.3 The Java Programming Language 6 1.4 Becoming Familiar with Your Programming Environment 8 1.5 Analyzing Your First Program 12 1.6 Errors 15 1.7 Problem Solving: Algorithm Design 16 CHATER 2 USING OBJECTS 33 2.
1 Objects and Classes 34 2.2 Variables 36 2.3 Calling Methods 43 2.4 Constructing Objects 48 2.5 Accessor and Mutator Methods 50 2.6 The API Documentation 52 2.7 Implementing a Test Program 55 2.8 Object References 57 2.
9 Graphical Applications 61 2.10 Ellipses, Lines, Text, and Color 66 CHATER 3 IMPLEMENTING CLASSES 81 3.1 Instance Variables and Encapsulation 82 3.2 Specifying the Public Interface of a Class 86 3.3 Providing the Class Implementation 93 3.4 Unit Testing 102 3.5 Problem Solving: Tracing Objects 105 3.6 Local Variables 107 3.
7 The this reference 109 3.8 Shape Classes 112 CHATER 4 FUNDAMENTAL DATA TYPES 131 4.1 Numbers 132 4.2 Arithmetic 139 4.3 Input and Output 147 4.4 Problem Solving: First Do it By Hand 154 4.5 Strings 156 CHATER 5 DECISIONS 179 5.1 The if Statement 180 5.
2 Comparing Values 186 5.3 Multiple Alternatives 196 5.4 Nested Branches 200 5.5 Problem Solving: Flowcharts 207 5.6 Problem Solving: Selecting Test Cases 210 5.7 Boolean Variables and Operators 213 5.8 Application: Input Validation 218 CHAPTER 6 LOOPS 241 6.1 The While Loop 242 6.
2 Problem Solving: Hand-Tracing 249 6.3 The For Loop 254 6.4 The Do Loop 262 6.5 Application: Processing Sentinel Values 263 6.6 Problem Solving: Storyboards 269 6.7 Common Loop Algorithms 272 6.8 Nested Loops 279 6.9 Application: Random Numbers and Simulations 283 6.
10 Using a Debugger 286 CHAPTER 7 ARRAYS AND ARRAY LISTS 311 7.1 Arrays 312 7.2 The Enhanced For Loop 321 7.3 Common Array Algorithms 322 7.4 Problem Solving: Adapting Algorithms 331 7.5 Problem Solving: Discovering Algorithms By Manipulating Physical Objects 336 7.7 Array Lists 347 7.8 Regression Testing 356 CHATER 8 DESIGNING CLASSES 379 8.
1 Discovering Classes 380 8.2 Designing Good Methods 381 8.3 Problem Solving: Patterns for Object Data 390 8.4 Static Variables and Methods 395 8.5 Packages 400 8.6 Unit Test Frameworks 407 CHAPTER 9 INHERITANCE 421 9.1 Inheritance Hierarchies 422 9.2 Implementing Subclasses 426 9.
3 Overriding Methods 431 9.4 Polymorphism 437 9.5 Object: The cosmic Superclass 448 CHAPTER 10 INTERFACES 463 10.1 Using Interfaces for Algorithm Reuse 464 10.2 Working with Interface Variables 471 10.3 The Comparable Interface 473 10.4 Using Interfaces for Callbacks 477 10.5 Inner Classes 481 10.
6 Mock Objects 483 10.7 Event Handling 484 10.8 Building Applications with Buttons 490 10.9 Processing Timer Events 494 10.10 Mouse Events 497 CHAPTER 11 INPUT/OUTPUT AND EXCEPTION HANDLING 513 11.1 Reading and Writing Text files 514 11.2 Text Input and Output 519 11.3 Command Line arguments 527 11.
4 Exception Handling 534 11.5 Application: Handling Input errors 545 CHAPTER 12 OBJECT-ORIENTED DESIGN 559 12.1 Classes and Their Responsibilities 560 12.2 Relationships between Classes 563 12.3 Application: Printing an Invoice 569 CHAPTER 13 RECURSION (WEB ONLY) 13.1 Triangle Numbers 13.2 Recursive Helper Methods 13.3 The Efficiency Of Recursion 13.
4 Permutations 13.5 Mutual Recursion 13.6 Backtracking CHAPTER 14 SORTING AND SEARCHING (WEB ONLY) 14.1 Selection Sort 14.2 Profiling the Selection Sort algorithm 14.3 Analyzing the Performance of the Selection Sort algorithm 14.4 Merge Sort 14.5 Analyzing the Merge Sort Algorithm 14.
6 Searching 14.7 Problem Solving: Estimating the Running Time of an Algorithm 14.8 Sorting and Searching in the Java Library CHAPTER 15 THE JAVA COLLECTIONS FRAMEWORK (WEB ONLY) 15.1 an Overview of the collections framework 15.2 Linked Lists 15.3 Sets 15.4 Maps 15.5 Stacks, Queues, and Priority Queues 15.
6 Stack and Queue applications APPENDICES APPENDIX A THE BASIC LATIN AND LATIN-1 SUBSETS OF UNICODE A-1 APPENDIX B JAVA OPERATOR SUMMARY A-5 APPENDIX C JAVA RESERVED WORD SUMMARY A-7 APPENDIX D THE JAVA LIBRARY A-9 APPENDIX E JAVA SYNTAX SUMMARY APPENDIX F TOOL SUMMARY APPENDIX G NUMBER SYSTEMS APPENDIX H UML SUMMARY APPENDIX I JAVA LANGUAGE CODING GUIDELINES APPENDIX J HTML SUMMARY GLOSSARY G-1 INDEX I-1 CREDITS C-1 ALPHABETICAL SYNTAX BOXES Arrays 313 Array Lists 347 Assignment 41 Calling a Superclass Method 431 Cast 143 Catching Exceptions 536 Class Declaration 89 Comparisons 187 Constant Declaration 136 Constructor with Superclass Initializer 436 Declaring an Interface 465 For Statement 254 If Statement 182 Implementing an Interface 467 Importing a Class from a Package 54 Input Statement 147 Instance Variable Declaration 83 Java Program 13 Object Construction 49 Package Specification 402 Subclass Declaration 428 The Enhanced For Loop 322 The Finally Clause 540 The Instance of Operator 451 The Throws Clause 539 Throwing an Exception 534 Two-Dimensional Array Declaration 341 While Statement 243 Variable Declaration 37.