Java: How to check if object is null?

前端 未结 9 1305
甜味超标
甜味超标 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:38

    Use google guava libs to handle is-null-check (deamon's update)

    Drawable drawable = Optional.of(Common.getDrawableFromUrl(this, product.getMapPath())).or(getRandomDrawable());
    

提交回复
热议问题