Preface Iii Special Features xxiv Introduction 1 1.1 Computer Programs 2 1.2 The Anatomy of a Computer 3 1.3 The Java Programming Language 5 1.4 Becoming Familiar with Your Programming Environment 7 1.5 Analyzing Your First Program 11 1.6 Errors 13 1.7 Problem Solving Algorithm Design 15 Using Objects 23 2.
1 Objects and Classes 24 2.2 Variables 26 2.3 Calling Methods 33 2.4 Constructing Objects 38 2.5 Accessor and Mutator Methods 40 2.6 The API Documentation 41 2.7 Implementing a Test Program 44 2.8 Object References 46 2.
9 Graphical Applications 49 2.10 Ellipses, Lines, Text, and Color 54 Implementing Classes 61 3.1 Instance Variables and Encapsulation 62 3.2 Specifying the Public Interface of a Class 66 3.3 Providing the Class Implementation 72 3.4 Unit Testing 81 3.5 Problem Solving Tracing Objects 84 3.6 Local Variables 86 3.
7 The this Reference 88 3.8 Shape Classes 90 Fundamental Data Types 99 4.1 Numbers 100 4.2 Arithmetic 107 4.3 Input and Output 114 4.4 Problem Solving First Do It By Hand 121 4.5 Strings 122 Decisions 131 5.1 The if Statement 132 5.
2 Comparing Values 137 5.3 Multiple Alternatives 146 5.4 Nested Branches 149 5.5 Problem Solving Flowcharts 156 5.6 PROBLEM SOLVING Selecting Test Cases 159 5.7 Boolean Variables and Operators 161 5.8 Application Input Validation 166 Loops 171 6.1 The while Loop 172 6.
2 Problem Solving Hand-Tracing 179 6.3 The for Loop 183 6.4 The do Loop 190 6.5 Application Processing Sentinel Values 192 6.6 Problem Solving Storyboards 197 6.7 Common Loop Algorithms 199 6.8 Nested Loops 206 6.9 Application Random Numbers and Simulations 209 6.
10 Using a Debugger 213 Arrays and Array Lists 221 7.1 Arrays 222 7.2 The Enhanced for Loop 230 7.3 Common Array Algorithms 232 7.4 Problem Solving Adapting Algorithms 240 7.5 Problem Solving Discovering Algorithms by Manipulating Physical Objects 245 7.6 Two-Dimensional Arrays 248 7.7 Array Lists 255 7.
8 Regression Testing 264 Designing Classes 271 8.1 Discovering Classes 272 8.2 Designing Good Methods 273 8.3 Problem Solving Patterns for Object Data 282 8.4 Static Variables and Methods 286 8.5 Problem Solving Solve a Simpler Problem First 291 8.6 Packages 295 8.7 Unit Test Frameworks 300 Inheritance 305 9.
1 Inheritance Hierarchies 306 9.2 Implementing Subclasses 310 9.3 Overriding Methods 314 9.4 Polymorphism 319 9.5 Object: The Cosmic Superclass 330 Interfaces 339 10.1 Using Interfaces for Algorithm Reuse 340 10.2 Working with Interface Variables 348 10.3 The Comparable Interface 350 10.
5 Inner Classes 360 10.6 Mock Objects 361 10.7 Event Handling 363 10.8 Building Applications with Buttons 368 10.9 Processing Timer Events 371 10.10 Mouse Events 374 Input/Output and Exception Handling 383 11.1 Reading and Writing Text Files 384 11.2 Text Input and Output 389 11.
3 Command Line Arguments 396 11.4 Exception Handling 403 11.5 APPLICATION Handling Input Errors 412 Object-Oriented Design 419 12.1 Classes and Their Responsibilities 420 12.2 Relationships Between Classes 423 12.3 APPLICATION Printing an Invoice 428 Recursion 443 13.1 Triangle Numbers 444 13.2 Recursive Helper Methods 452 13.
3 The Efficiency of Recursion 453 13.4 Permutations 459 13.5 Mutual Recursion 463 13.6 Backtracking 469 Sorting and Searching 477 14.1 Selection Sort 478 14.2 Profiling the Selection Sort Algorithm 481 14.3 Analyzing the Performance of the Selection Sort Algorithm 484 14.4 Merge Sort 488 14.
5 Analyzing the Merge Sort Algorithm 491 14.6 Searching 495 14.7 Problem Solving Estimating The Running 14.8 Sorting and Searching in the Java The Java Collections Framework 511 15.1 An Overview of the Collections Framework 512 15.2 Linked Lists 514 15.3 Sets 520 15.4 Maps 525 15.
5 Stacks, Queues, and Priority Queues 531 15.6 Stack and Queue Applications 534 Basic Data Structures 545 16.1 Implementing Linked Lists 546 16.2 Implementing Array Lists 560 16.3 Implementing Stacks and Queues 564 16.4 Implementing a Hash Table 570 Tree Structures 581 17.1 Basic Tree Concepts 582 17.2 Binary Trees 585 17.
3 Binary Search Trees 590 17.4 Tree Traversal 599 17.5 Red-Black Trees 605 17.6 Heaps 612 17.7 The Heapsort Algorithm 622 Generic Classes 629 18.1 Generic Classes and Type Parameters 630 18.2 Implementing Generic Types 631 18.3 Generic Methods 634 18.
4 Constraining Type Parameters 636 18.5 Type Erasure 639 Stream Processing 645 19.1 The Stream Concept 646 19.2 Producing Streams 648 19.3 Collecting Results 649 19.4 Transforming Streams 652 19.5 Lambda Expressions 654 19.6 The Optional Type 659 19.
7 Other Terminal Operations 661 19.8 Primitive-Type Streams 663 19.9 Grouping Results 665 19.10 Common Algorithms Revisited 667 Graphical User Interfaces 675 20.1 Layout Management 676 20.2 Processing Text Input 680 20.3 Choices 685 20.4 Menus 695 20.
5 Exploring the Swing Documentation 702 Advanced Input/Output* (Etext Only) 21.1 Readers, Writers, and Input/Output Streams 21.2 Binary Input and Output 21.3 Random Access 21.4 Object Input and Output Streams 21.5 File and Directory Operations Paths Multithreading* (Etext Only) 22.1 Running Threads 22.2 Terminating Threads 22.
3 Race Conditions 22.4 Synchronizing Object Access 22.5 Avoiding Deadlocks 22.6 Application Algorithm Animation Internet Networking* (Etext Only) Internet Networking* (Etext Only) 23.1 The Internet Protocol 23.2 Application Level Protocols 23.3 A Client Program 23.4 A Server Program 23.
5 URL Connections Relational Databases* (Etext Only) 24.1 Organizing Database Information 24.2 Queries 24.3 Installing a Database 24.4 Database Programming in Java Xml* (Etext Only) 25.1 XML Tags and Documents 25.2 Parsing XML Documents 25.3 Creating XML Documents 25.
4 Validating XML Documents 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 language coding Guidelines a-38 Appendix f tool summary (etext only) Appendix g number systems (etext only) Appendix h uml summary (etext only) Appendix i java syntax summary (etext only) Appendix j html summary (etext only) Glossary g-1 Index i-1 Credits c-1 Quick reference c-3.