void (final LinkedList<? super String> recentEntries, final String newEntry) { final int oldIndex = recentEntries.indexOf(newEntry); if (oldIndex >= 0) { recentEntries.remove(oldIndex); } else if (recentEntries.size() == myRecentsNumberToKeep) { recentEntries.removeLast(); } recentEntries.addFirst(newEntry); }