The code shown below shows a method Get
which gets string search
with default value: ""
.
How can the value possibly be null when search
has a non-null default value and is never changed?
How can the value possibly be null when search has a non-null default value and is never changed?
If you explicitly pass null
to the method (or a variable which is null), the default is not used.
The default value is only used if you call the method without the parameter in place, in which case the compiler "fills in" the default value for you. If you call the method with something, including null
or a object variable which is null
, you will get a null value there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With