Think Java: How to Think Like a Computer Scientist

Think Java: How to Think Like a Computer Scientist

Think Java: How to Think Like a Computer Scientist

Think Java: How to Think Like a Computer Scientist

Paperback(2nd ed.)

$49.99 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores

Related collections and offers


Overview

Think Java is a hands-on introduction to computer science and programming used by many universities and high schools around the world. Its conciseness, emphasis on vocabulary, and informal tone make it particularly appealing for readers with little or no experience. The book starts with the most basic programming concepts and gradually works its way to advanced object-oriented techniques.

In this fully updated and expanded edition, authors Allen Downey and Chris Mayfield introduce programming as a means for solving interesting problems. Each chapter presents material for one week of a college course and includes exercises to help you practice what you’ve learned. Along the way, you’ll see nearly every topic required for the AP Computer Science A exam and Java SE Programmer I certification.

  • Discover one concept at a time: tackle complex topics in a series of small steps with multiple examples
  • Understand how to formulate problems, think creatively about solutions, and develop, test, and debug programs
  • Learn about input and output, decisions and loops, classes and methods, strings and arrays, recursion and polymorphism
  • Determine which program development methods work best for you, and practice the important skill of debugging

Product Details

ISBN-13: 9781492072508
Publisher: O'Reilly Media, Incorporated
Publication date: 12/17/2019
Edition description: 2nd ed.
Pages: 323
Sales rank: 1,122,373
Product dimensions: 6.90(w) x 9.10(h) x 0.80(d)

About the Author

Allen B. Downey is a Professor of Computer Science at Olin College of Engineering. He has taught at Wellesley College, Colby College, and U.C. Berkeley. He has a Ph.D. in Computer Science from U.C. Berkeley, and Master’s and Bachelor’s degrees from MIT. Downey is the creator of the bestselling Think series for O’Reilly, including Think Python, Think Complexity, Think DSP, and Think Bayes.

Chris Mayfield is an Assistant Professor of Computer Science at James Madison University, with a research focus on CS education and professional development. He has a Ph.D. in Computer Science from Purdue Universityand Bachelor's degrees in CS and German from the University of Utah.

Table of Contents

Preface ix

1 Computer Programming 1

What Is a Computer? 1

What Is Programming? 2

The Hello World Program 3

Compiling Java Programs 4

Displaying Two Messages 6

Formatting Source Code 6

Using Escape Sequences 7

What Is Computer Science? 8

Debugging Programs 9

Vocabulary 10

Exercises 12

2 Variables and Operators 15

Declaring Variables 15

Assigning Variables 16

Memory Diagrams 17

Printing Variables 18

Arithmetic Operators 19

Floating-Point Numbers 20

Rounding Errors 21

Operators for Strings 22

Compiler Error Messages 23

Other Types of Errors 24

Vocabulary 25

Exercises 27

3 Input and Output 29

The System Class 29

The Scanner Class 30

Language Elements 31

Literals and Constants 32

Formatting Output 34

Reading Error Messages 35

Type Cast Operators 36

Remainder Operator 37

Putting It All Together 38

The Scanner Bug 39

Vocabulary 40

Exercises 41

4 Methods and Testing 45

Defining New Methods 45

Flow of Execution 46

Parameters and Arguments 47

Multiple Parameters 49

Stack Diagrams 50

Math Methods 51

Composition 52

Return Values 53

Incremental Development 54

Vocabulary 56

Exercises 57

5 Conditionals and Logic 63

Relational Operators 63

The if-else Statement 64

Chaining and Nesting 65

The switch Statement 66

Logical Operators 67

De Morgan's Laws 69

Boolean Variables 69

Boolean Methods 70

Validating Input 71

Example Program 72

Vocabulary 73

Exercises 74

6 Loops and Strings 79

The while Statement 79

Increment and Decrement 81

The for Statement 81

Nested Loops 83

Characters 84

Which Loop to Use 85

String Iteration 86

The indexOf Method 87

Substrings 87

String Comparison 88

String Formatting 89

Vocabulary 90

Exercises 91

7 Arrays and References 95

Creating Arrays 96

Accessing Elements 97

Displaying Arrays 98

Copying Arrays 99

Traversing Arrays 100

Generating Random Numbers 102

Building a Histogram 103

The Enhanced for Loop 104

Counting Characters 105

Vocabulary 107

Exercises 108

8 Recursive Methods 111

Recursive Void Methods 111

Recursive Stack Diagrams 113

Value-Returning Methods 114

The Leap of Faith 116

Counting Up Recursively 117

Binary Number System 118

Recursive Binary Method 119

CodingBat Problems 120

Vocabulary 122

Exercises 123

9 Immutable Objects 129

Primitives Versus Objects 129

The null Keyword 130

Strings Are Immutable 131

Wrapper Classes 132

Command-Line Arguments 134

Argument Validation 135

BigInteger Arithmetic 135

Incremental Design 137

More Generalization 139

Vocabulary 140

Exercises 141

10 Mutable Objects 147

Point Objects 147

Objects as Parameters 148

Objects as Return Values 149

Rectangles Are Mutable 150

Aliasing Revisited 151

Java Library Source 152

Class Diagrams 153

Scope Revisited 154

Garbage Collection 154

Mutable Versus Immutable 155

StringBuilder Objects 155

Vocabulary 157

Exercises 158

11 Designing Classes 161

The Time Class 161

Constructors 162

Value Constructors 164

Getters and Setters 165

Displaying Objects 167

The toString Method 167

The equals Method 168

Adding Times 170

Vocabulary 172

Exercises 173

12 Arrays of Objects 175

Card Objects 175

Card toString 177

Class Variables 178

The compareTo Method 179

Cards Are Immutable 180

Arrays of Cards 181

Sequential Search 183

Binary Search 183

Tracing the Code 184

Vocabulary 185

Exercises 186

13 Objects of Arrays 189

Decks of Cards 189

Shuffling Decks 190

Selection Sort 192

Merge Sort 192

Subdecks 193

Merging Decks 194

Adding Recursion 195

Static Context 196

Piles of Cards 197

Playing War 199

Vocabulary 200

Exercises 201

14 Extending Classes 205

CardCollection 206

Inheritance 208

Dealing Cards 209

The Player Class 211

The Eights Class 212

Class Relationships 215

Vocabulary 216

Exercises 216

15 Arrays of Arrays 219

Conway's Game of Life 219

The Cell Class 221

Two-Dimensional Arrays 222

The GridCanvas Class 223

Other Grid Methods 224

Starting the Game 225

The Simulation Loop 226

Exception Handling 227

Counting Neighbors 227

Updating the Grid 229

Vocabulary 231

Exercises 231

16 Reusing Classes 235

Langton's Ant 235

Refactoring 237

Abstract Classes 238

UML Diagram 240

Vocabulary 241

Exercises 241

17 Advanced Topics 243

Polygon Objects 243

Adding Color 244

Regular Polygons 245

More Constructors 247

An Initial Drawing 248

Blinking Polygons 250

Interfaces 251

Event Listeners 253

Timers 256

Vocabulary 257

Exercises 258

A Tools 259

B Javadoc 271

C Graphics 279

D Debugging 287

Index 299

From the B&N Reads Blog

Customer Reviews