Think Java 2e

This is the home page for the second edition of Think Java, by Allen Downey and Chris Mayfield.

You can download the current draft in PDF here.

Or read the interactive version hosted by Trinket.

The first edition of Think Java is also available.

Think Java is an introduction to computer science and programming intended for readers with little or no experience.  We start with the most basic concepts and are careful to define all terms when they are first used.  The book presents each new idea in a logical progression.  Larger topics, like control flow statements and object-oriented programming, are divided into smaller examples and introduced over the course of several chapters.

Here are the guiding principles that make the book the way it is:

  1. One concept at a time. We break down topics that give beginners trouble into a series of small steps, so that they can exercise each new concept in isolation before continuing.
  2. Balance of Java and concepts. The book is not primarily about Java; it uses code examples to demonstrate computer science. Most chapters start with language features and end with concepts.
  3. Conciseness. An important goal of the book is to be small enough so that students can read and understand the entire text in a one-semester college or AP course.
  4. Emphasis on vocabulary. We try to introduce the minimum number of terms and define them carefully when they are first used. We also organize them in glossaries at the end of each chapter.
  5. Program development. There are many strategies for writing programs, including bottom-up, top-down, and others. We demonstrate multiple program development techniques, allowing readers to choose methods that work best for them.
  6. Multiple learning curves. To write a program, you have to understand the algorithm, know the programming language, and be able to debug errors. We discuss these and other aspects throughout the book, and include an appendix that summarizes our advice.

Most of the code examples in this book are available for download from the ThinkJavaCode2 repository on GitHub.  Instructions for working with the repository are in the preface of the book.

Think Java is a free textbook available under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.  Readers are free to copy and distribute the text; they are also free to modify it, which allows them to adapt the book to different needs, and to help develop new material.  The LaTeX source for this book is in the ThinkJava2 repository on GitHub.