Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time


Supporting code for Think Java, 2nd edition. Copyright (c) 2020 Allen B. Downey and Chris Mayfield. This edition was published in December 2019 by O'Reilly Media (ISBN 9781492072508).

This repository contains the code examples from the book and starter code for some exercises. There are several ways you can work with the code:

  • You can create a copy of this repository on GitHub by clicking the "Fork" button. If you don't already have a GitHub account, you'll need to create one. After forking, you'll have your own repository on GitHub that you can use to keep track of code you write. Then you can "clone" the repository, which downloads a copy of the files to your computer.

  • Alternatively, you could clone the original repository without forking. If you choose this option, you don't need a GitHub account, but you won't be able to save your changes on GitHub.

  • If you don't want to use Git at all, you can download the code in a ZIP archive using the "Clone or download" button, or this link:

To clone a repository, you need Git installed on your computer (see If you use Git from the command line, you can clone the original repository like this:

git clone

After you clone the repository or unzip the ZIP file, you should have a directory named ThinkJavaCode2 with a subdirectory for each chapter in the book.

The examples in this book were developed and tested using OpenJDK 11. If you are using a more recent version, everything should still work. If you are using an older version, some of the examples might not.


Supporting code for Think Java, 2nd edition, by Allen Downey and Chris Mayfield.