There is a possiblity that this may be a dupicate question. I initialize a String variable to null.I may or may not update it with a value.Now I want to check whether this v
If you use
if (x == null)
you will not get a NullPointerException.
NullPointerException
I suspect you're doing:
if (x.y == null)
which is throwing because x is null, not because x.y is null.
x
x.y
If that doesn't explain it, please post the code you're using to test for nullity.