I am creating an application which retrieves images from the web. In case the image cannot be retrieved another local image should be used.
While trying to execute the f
Drawable drawable = Common.getDrawableFromUrl(this, product.getMapPath());
if (drawable == null) {
drawable = getRandomDrawable();
}
The equals()
method checks for value equality, which means that it compares the contents of two objects. Since null
is not an object, this crashes when trying to compare the contents of your object to the contents of null
.
The ==
operator checks for reference equality, which means that it looks whether the two objects are actually the very same object. This does not require the objects to actually exist; two nonexistent objects (null
references) are also equal.