

(3rd ed.)
-
SHIP THIS ITEMIn stock. Ships in 6-10 days.PICK UP IN STORE
Your local store may have stock of this item.
Available within 2 business hours
Related collections and offers
Overview
Product Details
ISBN-13: | 9781119186717 |
---|---|
Publisher: | Wiley |
Publication date: | 05/01/2017 |
Edition description: | 3rd ed. |
Pages: | 624 |
Product dimensions: | 7.90(w) x 9.90(h) x 1.00(d) |
Table of Contents
Preface vSpecial Features xxvi
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 7
VE1 Compiling and Running a Program
1.5 Analyzing Your First Program 11
1.6 Errors 14
1.7 PROBLEM SOLVING Algorithm Design 15
The Algorithm Concept 16
An Algorithm for Solving an Investment Problem 17
Pseudocode 18
From Algorithms to Programs 18
HT1 Describing an Algorithm with Pseudocode 19
WE1 Writing an Algorithm for Tiling a Floor 21
VE2 Dividing Household Expenses
2 Fundamental Data Types 31
2.1 Variables 32
Variable Declarations 32
Number Types 34
Variable Names 35
The Assignment Statement 36
Constants 37
Comments 37
ST1 Numeric Types in Java 41
ST2 Big Numbers 42
2.2 Arithmetic 43
Arithmetic Operators 43
Increment and Decrement 43
Integer Division and Remainder 44
Powers and Roots 45
Converting Floating-Point Numbers to Integers 46
J81 Avoiding Negative Remainders 49
ST3 Combining Assignment and Arithmetic 49
VE1 Using Integer Division
2.3 Input and Output 50
Reading Input 50
Formatted Output 52
HT1 Carrying Out Computations 56
WE1 Computing the Cost of Stamps
2.4 PROBLEM SOLVING First Do it By Hand 59
WE2 Computing Travel Time
2.5 Strings 61
The String Type 61
Concatenation 61
String Input 62
Escape Sequences 62
Strings and Characters 63
Substrings 63
ST4 Instance Methods and Static Methods 66
ST5 Using Dialog Boxes for Input and Output 67
VE2 Computing Distances on Earth
3 Decisions 83
3.1 The if Statement 84
ST1 The Conditional Operator 89
3.2 Comparing Numbers and Strings 90
ST2 Lexicographic Ordering of Strings 94
HT1 Implementing an if Statement 95
WE1 Extracting the Middle
3.3 Multiple Alternatives 98
ST3 The switch Statement 101
3.4 Nested Branches 102
ST4 Enumeration Types 107
VE1 Computing the Plural of an English Word
3.5 PROBLEM SOLVING Flowcharts 107
3.6 PROBLEM SOLVING Test Cases 110
ST5 Logging 112
3.7 Boolean Variables and Operators 113
ST6 Short-Circuit Evaluation of Boolean Operators 116
ST7 De Morgan’s Law 117
3.8 APPLICATION Input Validation 118
VE2 The Genetic Code
4 Loops 142
4.1 The while Loop 142
4.2 PROBLEM SOLVING Hand-Tracing 149
4.3 The for Loop 152
4.4 The do Loop 158
4.5 APPLICATION Processing Sentinel Values 160
ST1 The “Loop and a Half” Problem and the break Statement 162
ST2 Redirection of Input and Output 163
VE1 Evaluating a Cell Phone Plan
4.6 PROBLEM SOLVING Storyboards 164
4.7 Common Loop Algorithms 167
Sum and Average Value 167
Counting Matches 167
Finding the First Match 168
Prompting Until a Match is Found 169
Maximum and Minimum 169
Comparing Adjacent Values 170
HT1 Writing a Loop 171
WE1 Credit Card Processing
4.8 Nested Loops 174
WE2 Manipulating the Pixels in an Image
4.9 PROBLEM SOLVING Solve a Simpler Problem First 178
4.10 APPLICATION Random Numbers and Simulations 182
Generating Random Numbers 182
Simulating Die Tosses 183
The Monte Carlo Method 184
ST3 Drawing Graphical Shapes 186
VE1 Drawing a Spiral
5 Methods 211
5.1 Methods as Black Boxes 212
5.2 Implementing Methods 214
5.3 Parameter Passing 217
5.4 Return Values 220
HT1 Implementing a Method 222
WE1 Generating Random Passwords
5.5 Methods Without Return Values 224
5.6 PROBLEM SOLVING Reusable Methods 225
5.7 PROBLEM SOLVING Stepwise Refinement 229
WE2 Calculating a Course Grade
5.8 Variable Scope 236
VE1 Debugging
5.9 Recursive Methods (Optional) 240
HT2 Thinking Recursively 243
VE2 Fully Justified Text
6 Arrays and Array Lists 261
6.1 Arrays 262
Declaring and Using Arrays 262
Array References 265
Partially Filled Arrays 266
6.2 The Enhanced for Loop 269
6.3 Common Array Algorithms 270
Filling 270
Sum and Average Value 271
Maximum and Minimum 271
Element Separators 271
Linear Search 272
Removing an Element 272
Inserting an Element 273
Swapping Elements 274
Copying Arrays 275
Reading Input 276
ST1 Sorting with the Java Library 279
ST2 Binary Search 279
6.4 Using Arrays with Methods 280
ST3 Methods with a Variable Number of Parameters 284
6.5 PROBLEM SOLVING Adapting Algorithms 284
HT1 Working with Arrays 287
WE1 Rolling the Dice
6.6 PROBLEM SOLVING Discovering Algorithms by Manipulating Physical Objects 291
VE1 Removing Duplicates from an Array
6.7 Two-Dimensional Arrays 294
Declaring Two-Dimensional Arrays 295
Accessing Elements 295
Locating Neighboring Elements 296
Computing Row and Column Totals 297
Two-Dimensional Array Parameters 298
WE2 A World Population Table
ST4 Two-Dimensional Arrays with Variable Row Lengths 300
ST5 Multidimensional Arrays 301
6.8 Array Lists 301
Declaring and Using Array Lists 302
Using the Enhanced for Loop with Array Lists 304
Copying Array Lists 305
Array Lists and Methods 305
Wrappers and Auto-boxing 305
Using Array Algorithms with Array Lists 307
Storing Input Values in an Array List 307
Removing Matches 307
Choosing Between Array Lists and Arrays 308
ST6 The Diamond Syntax 311
VE2 Game of Life
7 Input/Output and Exception Handling 331
7.1 Reading and Writing Text Files 332
ST1 Reading Web Pages 335
ST2 File Dialog Boxes 335
ST3 Reading and Writing Binary Data 336
7.2 Text Input and Output 337
Reading Words 337
Reading Characters 338
Classifying Characters 338
Reading Lines 339
Scanning a String 340
Converting Strings to Numbers 340
Avoiding Errors When Reading Numbers 340
Mixing Number, Word, and Line Input 341
Formatting Output 342
ST4 Regular Expressions 344
ST5 Reading an Entire File 344
VE1 Computing a Document’s Readability
7.3 Command Line Arguments 345
HT1 Processing Text Files 348
WE1 Analyzing Baby Names
7.4 Exception Handling 352
Throwing Exceptions 352
Catching Exceptions 354
Checked Exceptions 355
Closing Resources 357
ST6 Assertions 360
ST7 The try/finally Statement 360
7.5 APPLICATION Handling Input Errors 361
VE2 Detecting Accounting Fraud
8 Objects and Classes 375
8.1 Object-Oriented Programming 376
8.2 Implementing a Simple Class 378
8.3 Specifying the Public Interface of a Class 381
ST1 The javadoc Utility 384
8.4 Designing the Data Representation 385
8.5 Implementing Instance Methods 386
8.6 Constructors 389
ST2 Overloading 393
8.7 Testing a Class 393
HT1 Implementing a Class 395
WE1 Implementing a Menu Class
VE1 Paying Off a Loan
8.8 Problem Solving: Tracing Objects 399
8.9 Object References 403
Shared References 403
The null Reference 405
The this Reference 405
ST3 Calling One Constructor from Another 408
8.10 Static Variables and Methods 408
8.11 PROBLEM SOLVING Patterns for Object Data 410
Keeping a Total 411
Counting Events 411
Collecting Values 412
Managing Properties of an Object 413
Modeling Objects with Distinct States 413
Describing the Position of an Object 414
VE2 Modeling a Robot Escaping from a Maze
8.12 Packages 417
Organizing Related Classes into Packages 417
Importing Packages 418
Package Names 419
Packages and Source Files 419
ST4 Package Access 421
HT2 Programming with Packages 421
9 Inheritance and Interfaces 437
9.1 Inheritance Hierarchies 438
9.2 Implementing Subclasses 442
9.3 Overriding Methods 446
ST1 Calling the Superclass Constructor 451
9.4 Polymorphism 452
ST2 Dynamic Method Lookup and the Implicit Parameter 455
ST3 Abstract Classes 456
ST4 Final Methods and Classes 457
ST5 Protected Access 458
HT1 Developing an Inheritance Hierarchy 458
WE1 Implementing an Employee Hierarchy for Payroll Processing
VE1 Building a Discussion Board
9.5 Object: The Cosmic Superclass 463
Overriding the toString Method 464
The equals Method 465
The instanceof Operator 466
ST6 Inheritance and the toString Method 468
ST7 Inheritance and the equals Method 469
9.6 Interface Types 470
Defining an Interface 470
Implementing an Interface 472
The Comparable Interface 474
ST8 Constants in Interfaces 476
ST9 Generic Interface Types 476
J81 Static Methods in Interfaces 477
J82 Default Methods 477
ST10 Function Objects 478
J83 Lambda Expressions 479
WE2 Investigating Number Sequences
VE2 Drawing Geometric Shapes
10 Graphical User Interfaces 493
10.1 Frame Windows 494
Displaying a Frame 494
Adding User-Interface Components to a Frame 495
Using Inheritance to Customize Frames 497
ST1 Adding the main Method to the Frame Class 498
10.2 Events and Event Handling 498
Listening to Events 499
Using Inner Classes for Listeners 501
APPLICATION Showing Growth of an Investment 503
ST2 Local Inner Classes 507
ST3 Anonymous Inner Classes 508
J81 Lambda Expressions for Event Handling 509
10.3 Processing Text Input 509
Text Fields 509
Text Areas 511
10.4 Creating Drawings 515
Drawing on a Component 515
Ovals, Lines, Text, and Color 517
APPLICATION Visualizing the Growth of an Investment 520
HT1 Drawing Graphical Shapes 525
WE1 Coding a Bar Chart Creator
VE1 Solving Crossword Puzzles
11 Advanced User Interfaces (Web Only)
11.1 Layout Management
11.2 Choices
Radio Buttons
Check Boxes
Combo Boxes
HT1 Laying Out a User Interface
WE1 Programming a Working Calculator
11.3 Menus
11.4 Exploring the Swing Documentation
11.5 Using Timer Events for Animations
11.6 Mouse Events
ST1 Keyboard Events
ST2 Event Adapters
WE2 Adding Mouse and Keyboard Support to the Bar Chart Creator
VE1 Designing a Baby Naming Program
12 Object-Oriented Design (Web Only)
12.1 Classes and Their Responsibilities
Discovering Classes
The CRC Card Method
Cohesion
12.2 Relationships Between Classes
Dependency
Aggregation
Inheritance
HT1 Using CRC Cards and UML Diagrams in Program Design
ST1 Attributes and Methods in UML Diagrams
ST2 Multiplicities
ST3 Aggregation, Association, and Composition
12.3 APPLICATION Printing an Invoice
Requirements
CRC Cards
UML Diagrams
Method Documentation
Implementation
WE1 Simulating an Automatic Teller Machine
13 Recursion (Web Only)
13.1 Triangle Numbers
HT1 Thinking Recursively
WE1 Finding Files
13.2 Recursive Helper Methods
13.3 The Efficiency of Recursion
13.4 Permutations
13.5 Mutual Recursion
13.6 Backtracking
WE2 Towers of Hanoi
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
ST1 Oh, Omega, and Theta
ST2 Insertion Sort
14.4 Merge Sort
14.5 Analyzing the Merge Sort Algorithm
ST3 The Quicksort Algorithm
14.6 Searching
Linear Search
Binary Search
14.7 PROBLEM SOLVING Estimating the Running Time of an Algorithm
Linear Time
Quadratic Time
The Triangle Pattern
Logarithmic Time
14.8 Sorting and Searching in the Java Library
Sorting
Binary Search
Comparing Objects
ST4 The Comparator Interface
J81 Comparators with Lambda Expressions
WE1 Enhancing the Insertion Sort Algorithm
15 The JAVA Collections Framework (Web Only)
15.1 An Overview of the Collections Framework
15.2 Linked Lists
The Structure of Linked Lists
The LinkedList Class of the Java
Collections Framework
List Iterators
15.3 Sets
Choosing a Set Implementation
Working with Sets
15.4 Maps
J81 Updating Map Entries
HT1 Choosing a Collection
WE1 Word Frequency
ST1 Hash Functions
15.5 Stacks, Queues, and Priority Queues
Stacks
Queues
Priority Queues
15.6 Stack and Queue Applications
Balancing Parentheses
Evaluating Reverse Polish Expressions
Evaluating Algebraic Expressions
Backtracking
WE2 Simulating a Queue of Waiting Customers
VE1 Building a Table of Contents
ST2 Reverse Polish Notation
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
Appendix F Tool Summary
Appendix G Number Systems
Appendix H UML Summary
Appendix I JAVA Syntax Summary
Appendix J HTML Summary
Glossary G-1
Index I-1
Credits C-1