We run our game and see whether it works. Unfortunately an
ArrayIndexOutOfBoundsException
greets us when we try to play our game.
Our unit test passes, but when we look at the output we see that after
shuffle, our indexes are [-1, -3, 19, -14, 10, 2, -25, 14, 19, 24]
. Ooops.
That's not really what we wanted to see. We definitely made a mistake in our
code.
We now add more code to our test to ensure that the numbers in the array are
the same as before our shuffle. We do this by sorting the array and again
converting it to a String
. The value of sorted
should be the same as beforeShuffle
.
We hope you enjoyed this tutorial. If you did, you will also enjoy our courses. We suggest you start with Extreme Java - Advanced Java, followed by Extreme Java - Concurrency Performance for Java 8.
We deliver relevant courses, by top Java developers to produce more resourceful and efficient programmers within their organisations.
We can help make your Java application run faster and trouble-shoot concurrency and performance bugs...