About Question enthuware.ocpjp.v8.2.1399 :
Posted: Thu Dec 31, 2020 9:54 pm
If 'number' is null, then won't number.length() == 10 throw a NullPointerException? Which would be another reason why this code will not work in all situations if assertions are enabled? And would that make the code syntactically incorrect? Or does this have nothing to do with syntactical correctness?
public void processPhoneNumber(String number) {
assert number != null && number.length() == 10 : "Invalid phone number"; ... }
Thanks
public void processPhoneNumber(String number) {
assert number != null && number.length() == 10 : "Invalid phone number"; ... }
Thanks