
Think Java
How to Think Like a Computer Scientist
Publisher: O'Reilly Media
Release Date: May 2016
Pages: 252
Read on Safari with a 10-day trial
Start your free trial now Buy on AmazonWhere’s the cart? Now you can get everything on Safari. To purchase books, visit Amazon or your favorite retailer. Questions? See our FAQ or contact customer service:
1-800-889-8969 / 707-827-7019
support@oreilly.com
Currently used at many colleges, universities, and high schools, this hands-on introduction to computer science is ideal for people with little or no programming experience. The goal of this concise book is not just to teach you Java, but to help you think like a computer scientist. You’ll learn how to program—a useful skill by itself—but you’ll also discover how to use programming as a means to an end.
Authors Allen Downey and Chris Mayfield start with the most basic concepts and gradually move into topics that are more complex, such as recursion and object-oriented programming. Each brief chapter covers the material for one week of a college course and includes exercises to help you practice what you’ve learned.
- Learn one concept at a time: tackle complex topics in a series of small steps with examples
- Understand how to formulate problems, think creatively about solutions, and write programs clearly and accurately
- Determine which development techniques work best for you, and practice the important skill of debugging
- Learn relationships among input and output, decisions and loops, classes and methods, strings and arrays
- Work on exercises involving word games, graphics, puzzles, and playing cards
Table of Contents
-
Chapter 1 The Way of the Program
-
What Is Programming?
-
What Is Computer Science?
-
Programming Languages
-
The Hello World Program
-
Displaying Strings
-
Escape Sequences
-
Formatting Code
-
Debugging Code
-
Vocabulary
-
Exercises
-
-
Chapter 2 Variables and Operators
-
Declaring Variables
-
Assignment
-
State Diagrams
-
Printing Variables
-
Arithmetic Operators
-
Floating-Point Numbers
-
Rounding Errors
-
Operators for Strings
-
Composition
-
Types of Errors
-
Vocabulary
-
Exercises
-
-
Chapter 3 Input and Output
-
The System Class
-
The Scanner Class
-
Program Structure
-
Inches to Centimeters
-
Literals and Constants
-
Formatting Output
-
Centimeters to Inches
-
Modulus Operator
-
Putting It All Together
-
The Scanner Bug
-
Vocabulary
-
Exercises
-
-
Chapter 4 Void Methods
-
Math Methods
-
Composition Revisited
-
Adding New Methods
-
Flow of Execution
-
Parameters and Arguments
-
Multiple Parameters
-
Stack Diagrams
-
Reading Documentation
-
Writing Documentation
-
Vocabulary
-
Exercises
-
-
Chapter 5 Conditionals and Logic
-
Relational Operators
-
Logical Operators
-
Conditional Statements
-
Chaining and Nesting
-
Flag Variables
-
The return Statement
-
Validating Input
-
Recursive Methods
-
Recursive Stack Diagrams
-
Binary Numbers
-
Vocabulary
-
Exercises
-
-
Chapter 6 Value Methods
-
Return Values
-
Writing Methods
-
Method Composition
-
Overloading
-
Boolean Methods
-
Javadoc Tags
-
More Recursion
-
Leap of Faith
-
One More Example
-
Vocabulary
-
Exercises
-
-
Chapter 7 Loops
-
The while Statement
-
Generating Tables
-
Encapsulation and Generalization
-
More Generalization
-
The for Statement
-
The do-while Loop
-
break and continue
-
Vocabulary
-
Exercises
-
-
Chapter 8 Arrays
-
Creating Arrays
-
Accessing Elements
-
Displaying Arrays
-
Copying Arrays
-
Array Length
-
Array Traversal
-
Random Numbers
-
Traverse and Count
-
Building a Histogram
-
The Enhanced for Loop
-
Vocabulary
-
Exercises
-
-
Chapter 9 Strings and Things
-
Characters
-
Strings Are Immutable
-
String Traversal
-
Substrings
-
The indexOf Method
-
String Comparison
-
String Formatting
-
Wrapper Classes
-
Command-Line Arguments
-
Vocabulary
-
Exercises
-
-
Chapter 10 Objects
-
Point Objects
-
Attributes
-
Objects as Parameters
-
Objects as Return Types
-
Mutable Objects
-
Aliasing
-
The null Keyword
-
Garbage Collection
-
Class Diagrams
-
Java Library Source
-
Vocabulary
-
Exercises
-
-
Chapter 11 Classes
-
The Time Class
-
Constructors
-
More Constructors
-
Getters and Setters
-
Displaying Objects
-
The toString Method
-
The equals Method
-
Adding Times
-
Pure Methods and Modifiers
-
Vocabulary
-
Exercises
-
-
Chapter 12 Arrays of Objects
-
Card Objects
-
Card toString
-
Class Variables
-
The compareTo Method
-
Cards Are Immutable
-
Arrays of Cards
-
Sequential Search
-
Binary Search
-
Tracing the Code
-
Recursive Version
-
Vocabulary
-
Exercises
-
-
Chapter 13 Objects of Arrays
-
The Deck Class
-
Shuffling Decks
-
Selection Sort
-
Merge Sort
-
Subdecks
-
Merging Decks
-
Adding Recursion
-
Vocabulary
-
Exercises
-
-
Chapter 14 Objects of Objects
-
Decks and Hands
-
CardCollection
-
Inheritance
-
Dealing Cards
-
The Player Class
-
The Eights Class
-
Class Relationships
-
Vocabulary
-
Exercises
-
-
Appendix Development Tools
-
Installing DrJava
-
DrJava Interactions
-
Command-Line Interface
-
Command-Line Testing
-
Running Checkstyle
-
Tracing with a Debugger
-
Testing with JUnit
-
Vocabulary
-
-
Appendix Java 2D Graphics
-
Creating Graphics
-
Graphics Methods
-
Example Drawing
-
Vocabulary
-
Exercises
-
-
Appendix Debugging
-
Compile-Time Errors
-
Run-Time Errors
-
Logic Errors
-