int getScore(String name) { // 先在Map中查找: Integer score = this.cache.get(name); if (score == null) { try { score = findInList(name); this.cache.put(name,score); } catch (Exception e) { System.out.println(e); } } return score == null ? -1 : score.intValue(); } Integer findInList(String name) { for (var ss : this.list) { if (ss.name.equals(name)) { return ss.score; } } throw new NullPointerException(name+"没有记录在案"); // return null; }
Sign in to make a reply
用户ily8tu6igg