4 ms·
Perhaps nothing, but he made an assumption that this would be wrong in this case (if it is is matter of discussion). But he did not give a way to fix this idio
by eveningcoffee 11y ago
Perhaps nothing, but he made an assumption that this would be wrong in this case (if it is is matter of discussion).
But he did not give a way to fix this idiomatically:
public String format(int percentage) {
if (percentage < 0) {
throw new IllegalArgumentException("Negative percentage not allowed.");
}
return percentage + "%";
}