int getScore(String name) {
// 先在Map中查找:
Integer score = this.cache.get(name);
if (score == null) {
// TODO:
score=findInList(name);
if(score!=null) this.cache.put(name, score);
}
return score == null ? -1 : score.intValue();
赞一个!
后面为什么要在!=null 中put呢?已经返回score了啊
Sign in to make a reply
IM卓荣
int getScore(String name) {
// 先在Map中查找:
Integer score = this.cache.get(name);
if (score == null) {
// TODO:
score=findInList(name);
if(score!=null) this.cache.put(name, score);
}
return score == null ? -1 : score.intValue();
}