Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public String put(String key, String value) {
- //Checking if the key appears either in the file or the cache
- if(containsKey(key)) {
- //Saves the old value
- String oldValue = get(key);
- //replaces and returns
- tm.put(key, value);
- return oldValue;
- }
- //Does not exist, so add to the cache
- else {
- tm.put(key, value);
- totalWords++;
- }
- return value;
- }
Add Comment
Please, Sign In to add comment