It seems not be be working in all cases. When e.g. changing GarageTest.java#L33 into an empty array, an ArrayIndexOutOfBoundsException is thrown. I think safest would be to perform a length check quite early in the call flow.