Voot: Integer.min is in Java7, so lets use Math.min so Java6 will work