Practice pieces


Efficiency

If you're struggling, here's one version:

BetterCode.java.

As mentioned on the last page, you wouldn't always trade off clarity against efficiency; just when it makes a big difference. Have a go at putting some elements back in, and see what difference they make.