It is an established good practice to validate method arguments at the beginning of the method body. For example you could check that the passed value is not negative before doing some calculation:
1
2
3
4
5
6
|
public
int
doSomeCalculation(
int
value) {
if
(value <
0
) {
throw
new
IllegalArgumentException(
"negative value"
);
|