Updating xml data using jsp
In this case, you would need to check for a null parameter and behave differently. For example, "The best way to avoid this type of exception is to always check for null when you did not create the object yourself." If the caller passes null, but null is not a valid argument for the method, then it's correct to throw the exception back at the caller because it's the caller's fault.
But, when you try to declare a reference type something different happens. In the most trivial cases the compiler will catch the problem and let you know that "num may not have been initialized" but sometimes you write code that does not directly create the object.This means I have a reference, but it isn't pointing to any object.