Java: How to check if object is null?

前端 未结 9 1309
甜味超标
甜味超标 2021-01-30 08:11

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

9条回答
  •  日久生厌
    2021-01-30 08:46

    DIY

    private boolean isNull(Object obj) {
        return obj == null;
    }
    

    Drawable drawable = Common.getDrawableFromUrl(this, product.getMapPath());
    if (isNull(drawable)) {
        drawable = getRandomDrawable();
    }
    

提交回复
热议问题