Learn Java the Hard Way (Second Edition)

Introduction: Java

Java is not a language for beginners. I am convinced that most “beginner” Java books only work for people who already know how to code or who are prodigies.

I can teach you Java, even if you have never programmed before and even if you are not a genius. But I am going to have to cheat a bit.

What I will teach you is Java. But it is not all of Java. I have to leave parts out because you’re not ready for them. If you think you are ready for the more complex parts of Java, then 1) you’re wrong, and 2) buy a different book. There are a great many books on the market that will throw all the complexity Java has to offer, faster than you can handle it.

In particular, I have one huge omission: I am going to avoid the topic of Object-Oriented Programming (OOP). I’m pretty sure that uncomfortable beginners can’t learn how to code well and also learn object-oriented programming at the same time. I have almost never seen it work.

I am writing a follow-up book that will cover Object-Oriented Programming and some of the more complex parts of Java. But you should finish this book first. I have been teaching students to program for many, many years, and I have never had a student come visit me from college and say “I wish you had spent less time on the fundamentals.”

What You Will Learn

In the final chapter you’ll write a not-so-simple text-based adventure game with levels loaded from text files. You should also be able to write a text-based card game like Hearts or Spades.

All the examples in this book will work in version 1.5 of Java or any newer version.

What You Will Not Learn

No graphics
I like graphics, and they’re not hard in Java compared to, say, C++, but I can’t cover everything and teach the basics well, so something had to go.
Object-oriented programming has no place in an introductory book, in my opinion.
No Android
Android apps are pretty complex, and if you’re a beginner, an app is way beyond your ability. Nothing in this book will hurt your chances of making an app, though, and the kinder, gentler pace may keep you going when other books would frustrate you into quitting.
No specific version
I will not cover anything about the differences between Java SE 7 and Java SE 8, for example. If you care about the difference, then this book is not for you.

I will also not cover anything that was only recently added to Java. This book is for learning the basics of programming and nothing has changed about the basics of Java in many years.

No Javascript
“Javascript” is the name of a programming language and “Java” is also the name of a programming language. These two languages have nothing to do with each other. They are completely unrelated.

I hope to write more books after this one. My second book will cover object-oriented programming in Java. My third book will cover making a simple Android app, assuming you have finished working through the first two books.

How to Use This Book

Although I have provided a zipfile containing the source code for all the exercises in the book, you should type them in.

For each exercise, type in the code. Yourself, by hand. How are you going to learn otherwise? None of my former students ever became great at programming by merely reading others’ code.

Work the Study Drills. Then watch the Study Drill videos (if you have them) to compare your solutions to mine. And by the end you will be able to code, at least a little.


Some chapters of this book are made available free to read online but you are not allowed to make copies for others without permission.

The materials provided for download may not be copied, scanned, or duplicated, or posted to a publicly accessible website, in whole or in part.

Educators who purchase this book and/or tutorial videos are given permission to utilize the curriculum solely for self-study or for one-to-one, face-to-face tutoring of a single student. Large-group teaching of this curriculum requires a site license.

Unless otherwise stated, all content is copyright 2013-2016 Graham Mitchell.

“Learn Java the Hard Way” is ©2013–2016 Graham Mitchell