There are many chances the value could be left null unintentionally, just
by not setting it in some execution path.

That is true, although unless we're careful about setting the defaults correctly we could also forget to set the value of the int, and unintentionally end up with 0 (rather than null) - that would avoid NPEs, but also give the "wrong" impression.

I'm fine with -1 as a flag value to indicate that there was a problem, and I can see that it's less error-prone (i.e. you won't get an NPE) from the user side to check for. I was just speculating as to the reason why we might have had null there in the original situation ;-)

Regards

ap

Reply via email to