You could use:
Bitmap bitmap = cache.get(key, null);
But understand that this is the same as get(key)
:
Bitmap bitmap = cache.get(key);
The best way to use get(key, default)
is to provide a generic default case, something to is a valid substitute when the key is not found.
But there is no good reason not to use if(get(key) != null)
as a quick replacement for contains()
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…