Contents
Chapter 0 Preface
Chapter 1 The way of the program
1.1 What is a programming language?
1.2 What is a program?
1.3 What is debugging?
1.4 Formal and natural languages
1.5 The first program
1.6 Glossary
1.7 Exercises
Chapter 2 Variables and types
2.1 More printing
2.2 Variables
2.3 Assignment
2.4 Printing variables
2.5 Keywords
2.6 Operators
2.7 Order of operations
2.8 Operators for
Strings
2.9 Composition
2.10 Glossary
2.11 Exercises
Chapter 3 Void methods
3.1 Floating-point
3.2 Converting from
double
to
int
3.3 Math methods
3.4 Composition
3.5 Adding new methods
3.6 Classes and methods
3.7 Programs with multiple methods
3.8 Parameters and arguments
3.9 Stack diagrams
3.10 Methods with multiple parameters
3.11 Methods that return values
3.12 Glossary
3.13 Exercises
Chapter 4 Conditionals and recursion
4.1 The modulus operator
4.2 Conditional execution
4.3 Alternative execution
4.4 Chained conditionals
4.5 Nested conditionals
4.6 The return statement
4.7 Type conversion
4.8 Recursion
4.9 Stack diagrams for recursive methods
4.10 Glossary
4.11 Exercises
Chapter 5 GridWorld: Part 1
5.1 Getting started
5.2
BugRunner
5.3 Exercises
Chapter 6 Value methods
6.1 Return values
6.2 Program development
6.3 Composition
6.4 Overloading
6.5 Boolean expressions
6.6 Logical operators
6.7 Boolean methods
6.8 More recursion
6.9 Leap of faith
6.10 One more example
6.11 Glossary
6.12 Exercises
Chapter 7 Iteration and loops
7.1 Multiple assignment
7.2 The
while
statement
7.3 Tables
7.4 Two-dimensional tables
7.5 Encapsulation and generalization
7.6 Methods and encapsulation
7.7 Local variables
7.8 More generalization
7.9 Glossary
7.10 Exercises
Chapter 8 Strings and things
8.1 Characters
8.2 Length
8.3 Traversal
8.4 Run-time errors
8.5 Reading documentation
8.6 The
indexOf
method
8.7 Looping and counting
8.8 Increment and decrement operators
8.9
String
s are immutable
8.10
String
s are incomparable
8.11 Glossary
8.12 Exercises
Chapter 9 Mutable objects
9.1 Packages
9.2
Point
objects
9.3 Instance variables
9.4 Objects as parameters
9.5 Rectangles
9.6 Objects as return types
9.7 Objects are mutable
9.8 Aliasing
9.9
null
9.10 Garbage collection
9.11 Objects and primitives
9.12 Glossary
9.13 Exercises
Chapter 10 GridWorld: Part 2
10.1 Termites
10.2 Langton’s Termite
10.3 Exercises
Chapter 11 Create your own objects
11.1 Class definitions and object types
11.2 Time
11.3 Constructors
11.4 More constructors
11.5 Creating a new object
11.6 Printing objects
11.7 Operations on objects
11.8 Pure functions
11.9 Modifiers
11.10 Fill-in methods
11.11 Incremental development and planning
11.12 Generalization
11.13 Algorithms
11.14 Glossary
11.15 Exercises
Chapter 12 Arrays
12.1 Accessing elements
12.2 Copying arrays
12.3 Arrays and objects
12.4
for
loops
12.5 Array length
12.6 Random numbers
12.7 Array of random numbers
12.8 Counting
12.9 The histogram
12.10 A single-pass solution
12.11 Glossary
12.12 Exercises
Chapter 13 Arrays of Objects
13.1 The Road Ahead
13.2
Card
objects
13.3 The
printCard
method
13.4 The
sameCard
method
13.5 The
compareCard
method
13.6 Arrays of cards
13.7 The
printDeck
method
13.8 Searching
13.9 Decks and subdecks
13.10 Glossary
13.11 Exercises
Chapter 14 Objects of Arrays
14.1 The
Deck
class
14.2 Shuffling
14.3 Sorting
14.4 Subdecks
14.5 Shuffling and dealing
14.6 Mergesort
14.7 Class variables
14.8 Glossary
14.9 Exercises
Chapter 15 Object-oriented programming
15.1 Programming languages and styles
15.2 Object methods and class methods
15.3 The
toString
method
15.4 The
equals
method
15.5 Oddities and errors
15.6 Inheritance
15.7 The class hierarchy
15.8 Object-oriented design
15.9 Glossary
15.10 Exercises
Chapter 16 GridWorld: Part 3
16.1
ArrayList
16.2 Interfaces
16.3
public
and
private
16.4 Game of Life
16.5
LifeRunner
16.6
LifeRock
16.7 Simultaneous updates
16.8 Initial conditions
16.9 Exercises
Appendix A Graphics
A.1 Java 2D Graphics
A.2
Graphics
methods
A.3 Coordinates
A.4 Color
A.5 Mickey Mouse
A.6 Glossary
A.7 Exercises
Appendix B Input and Output in Java
B.1 System objects
B.2 Keyboard input
B.3 File input
B.4 Catching exceptions
Appendix C Program development
C.1 Strategies
C.2 Failure modes
Appendix D Debugging
D.1 Syntax errors
D.2 Run-time errors
D.3 Logic errors
Like this book?
Are you using one of our books in a class?
We'd like to know about it. Please consider filling out
this short survey
.