Java Puzzle: Can You Change One Word to Fix This Bug? Win $250

 ● 04th Sep 2014

3 min read


As big fans of the book “Java Puzzlers” by Joshua Bloch and Neal Gafter, we’re always looking for new Java puzzles to solve. Since we haven’t seen good ones in a while, and as a tribute to their Java brainteasers we’ve decided to add a puzzle of our own. In their own words: “By working through the puzzles, you will become less likely to fall prey to these dangers in your code and more likely to spot them in code that you are reviewing or revising”. And besides, it’s also really fun. To spice it up a bit more we’ve added a $250 Amazon gift card to the one developer who manages to solve it. In one move. And give the right explanation as to what exactly happened there. We hope your kung fu is strong today.

The basics

Two teams are playing basketball, each is scoring points against the other and then suddenly – boom and game over. The project structure is pretty simple:
+– simulator
|   +–
|   +–
+– data
|   +–
|   +–
Two game simulator threads invoked by the main class, a simple data structure to hold the scores and the rest is up to you.


1. Head over to:
2. Clone, compile, run and see it crash and burn.
3. Solve the bug by changing ONE single keyword/token/identifier: it could be by replacing it, adding one, or deleting one.
4. Explain what caused the bug and how your solution fixes it.
5. Send us the solution and explanation to by Friday September 12, 12pm (PDT)
Update (12/9): We’d like to thanks everyone who participated and attempted to solve the puzzle, hope you had a good time! You can find the correct solution here – follow us on twitter to get updates on new puzzles.
** Please note that the explanation will be a crucial part of the answer. A wrong or an incomplete explanation may disqualify you even if you fixed the bug.
In case there’s more than one developer who solves the puzzle correctly, we’ll randomly choose one winner. In any case, the right answer will be published on the following week and all those who got the right answer will receive their recognition.
If you have any questions, please post them in the comments section below. Oh, and if you reach an answer, please don’t spoil it for everyone. At least not before the deadline. Good luck! 🙂

Java Developers – Know when and why production code breaks – read more

Already using Java 8? Try OverOps for Java 8

As a co-founder and VP Engineering at OverOps, Niv is responsible for making software magic happen. Previously, Niv was principal developer at Autodesk, where he led the development of the company's flagship mobile iOS and Android apps. Prior to that, Niv was the first employee at VisualTao. Recipe for Success: A Dvorak keyboard.

Troubleshooting Apache Spark Applications with OverOps OverOps’ ability to detect precisely why something broke and to see variable state is invaluable in a distributed compute environment.
Troubleshooting Apache Spark Applications with OverOps

Next Article

The Fastest Way to Why.

Eliminate the detective work of searching logs for the Cause of critical issues. Resolve issues in minutes.
Learn More